Only remove buffer callback if added

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).
This commit is contained in:
Allan Odgaard
2016-09-27 09:36:05 +02:00
parent f0a2a70998
commit e93f34b5ab

View File

@@ -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];