Commit 05d5153
committed
Fix EXC_BAD_ACCESS crash: MPDocument.editor IBOutlet was unsafe_unretained
Reported as a crash on the Underline toolbar action, but the bug wasn't
in the underline code path itself (toggleForMarkupPrefix:suffix: in
NSTextView+Autocomplete.m was untouched and correct) -- it was in how
MPDocument holds its reference to the editor view. 'editor' was the only
IBOutlet on the class declared unsafe_unretained; every sibling outlet
(toolbar, splitView, editorContainer, preview, ...) is weak. Traced via
git blame to the original 2014 project setup, never updated since.
unsafe_unretained is a raw, non-zeroing pointer: if the MPEditorView is
ever deallocated and recreated (window/layout churn), 'editor' keeps
pointing at freed memory, and the next message sent to it -- from any
action, not just Underline -- is a dangling-pointer access, i.e.
EXC_BAD_ACCESS. weak makes the pointer nil itself out instead, turning a
crash into a safe no-op.1 parent ae62fb1 commit 05d5153
2 files changed
Lines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
144 | 156 | | |
145 | 157 | | |
146 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
163 | 172 | | |
164 | 173 | | |
165 | 174 | | |
| |||
0 commit comments