From e93f34b5ab430d2fea34e28802f44c61c2ad6148 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Tue, 27 Sep 2016 09:36:05 +0200 Subject: [PATCH] Only remove buffer callback if added MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is incase our initializer fails, here dealloc is still called, but we didn’t get to add the callback so we should not try to remove it. Why our initializer would fail is beyond me, but I see a few crashes from this (though all from the same user on 10.8.5). --- Frameworks/document/src/OakDocumentEditor.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Frameworks/document/src/OakDocumentEditor.mm b/Frameworks/document/src/OakDocumentEditor.mm index a606a88e..9e2c35f4 100644 --- a/Frameworks/document/src/OakDocumentEditor.mm +++ b/Frameworks/document/src/OakDocumentEditor.mm @@ -94,7 +94,8 @@ static int32_t const NSWrapColumnWindowWidth = 0; [_document endUndoGrouping]; [self documentWillSave:_document]; - self.buffer.remove_callback(_buffer_callback.get()); + if(_document && _buffer_callback) + self.buffer.remove_callback(_buffer_callback.get()); _layout.reset(); _editor.reset(); [_document close];