From 7858a1aa837cbc21964922351908a8e07099cf27 Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Sat, 24 Oct 2015 15:20:55 +1100 Subject: When deallocating ScintillaView, null out the reference to it from SCIContentView since responsive scrolling causes callbacks after the deallocation. Also remove the scrollview to try to finalize it although it still lives for a short period. --- cocoa/ScintillaView.mm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'cocoa') diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index 180a7542e..3a73355c4 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -241,6 +241,9 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) */ - (void) viewWillDraw { + if (!mOwner) + return; + const NSRect *rects; NSInteger nRects = 0; [self getRectsBeingDrawn:&rects count:&nRects]; @@ -261,7 +264,8 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) */ - (void) prepareContentInRect: (NSRect) rect { - mOwner.backend->WillDraw(rect); + if (mOwner) + mOwner.backend->WillDraw(rect); #if MAC_OS_X_VERSION_MAX_ALLOWED > 1080 [super prepareContentInRect: rect]; #endif @@ -695,6 +699,8 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) */ - (NSRect)adjustScroll:(NSRect)proposedVisibleRect { + if (!mOwner) + return proposedVisibleRect; NSRect rc = proposedVisibleRect; // Snap to lines NSRect contentRect = [self bounds]; @@ -1216,6 +1222,9 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context { [[NSNotificationCenter defaultCenter] removeObserver:self]; delete mBackend; + mBackend = NULL; + mContent.owner = nil; + [scrollView removeFromSuperview]; [marginView release]; [super dealloc]; } -- cgit v1.2.3