From a9c49816a7008cf6e181fe66d7644a64c10faf17 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 23 Mar 2012 12:53:35 +0100 Subject: Cocoa: QCocoaWindow::clearNSWindow() needs to cleanup properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clearNSWindow() should also clear the delegate and remove the contentView from the window, since we are no longer using that window. Make sure the QCocoaWindow::~QCocoaWindow() doesn't release the m_contentView until after clearNSWindow(), to avoid crashes while trying to cleanup the window and view. Change-Id: Ia081488f629a4fd4cf10fb1053fb8183b1914d35 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 46c100649f..4f95489798 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -111,8 +111,8 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) QCocoaWindow::~QCocoaWindow() { - [m_contentView release]; clearNSWindow(m_nsWindow); + [m_contentView release]; [m_nsWindow release]; } @@ -449,7 +449,9 @@ void QCocoaWindow::setNSWindow(NSWindow *window) void QCocoaWindow::clearNSWindow(NSWindow *window) { + [window setDelegate:nil]; [[NSNotificationCenter defaultCenter] removeObserver:m_contentView]; + [m_contentView removeFromSuperviewWithoutNeedingDisplay]; } // Returns the current global screen geometry for the nswindow associated with this window. -- cgit v1.2.3