Cocoa GL context: do not crash when closing windows
authorLaszlo Agocs <lagocs83@gmail.com>
Fri, 31 Aug 2012 13:29:11 +0000 (16:29 +0300)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 20 Sep 2012 05:02:00 +0000 (07:02 +0200)
Running hellowindow and closing its windows one by one would result
in crashes without the additional checks for the presence of the
underlying native window.

Change-Id: Id32bdfda9a77936380b2e9a95fb56ceb52028d9d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
src/plugins/platforms/cocoa/qcocoaglcontext.mm

index 0292e02..4dd1962 100644 (file)
@@ -103,7 +103,7 @@ void QCocoaGLContext::setActiveWindow(QWindow *window)
     if (window == m_currentWindow.data())
         return;
 
-    if (m_currentWindow)
+    if (m_currentWindow && m_currentWindow.data()->handle())
         static_cast<QCocoaWindow *>(m_currentWindow.data()->handle())->setCurrentContext(0);
 
     Q_ASSERT(window->handle());
@@ -119,7 +119,7 @@ void QCocoaGLContext::setActiveWindow(QWindow *window)
 
 void QCocoaGLContext::doneCurrent()
 {
-    if (m_currentWindow)
+    if (m_currentWindow && m_currentWindow.data()->handle())
         static_cast<QCocoaWindow *>(m_currentWindow.data()->handle())->setCurrentContext(0);
 
     m_currentWindow.clear();