From 3f58fc00c91d5ff42f86b3f05c88119769bed910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 20 Mar 2013 15:06:37 +0100 Subject: [PATCH] Guard usage of m_cocoaPlatformWindow. m_cocoaPlatformWindow is cleared when Qt is "done" with the QNSWindow or QNSPanel to prevent messages from Cocoa calling into possibly stale pointers. Change-Id: Id42b794fedbd3e597a0c4b50584cca976ba74c0f Reviewed-by: Friedemann Kleint --- src/plugins/platforms/cocoa/qcocoawindow.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 4e567c6c63..0639d55aea 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -118,7 +118,7 @@ static bool isMouseEvent(NSEvent *ev) // Windows with a transient parent (such as combobox popup windows) // cannot become the main window: - if (m_cocoaPlatformWindow->window()->transientParent()) + if (m_cocoaPlatformWindow && m_cocoaPlatformWindow->window()->transientParent()) canBecomeMain = NO; return canBecomeMain; @@ -155,6 +155,9 @@ static bool isMouseEvent(NSEvent *ev) - (BOOL)canBecomeKeyWindow { + if (!m_cocoaPlatformWindow) + return NO; + // Only tool or dialog windows should become key: if (m_cocoaPlatformWindow->window()->type() == Qt::Tool || m_cocoaPlatformWindow->window()->type() == Qt::Dialog) return YES;