Cocoa GL context: do not crash when closing windows

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>
This commit is contained in:
Laszlo Agocs 2012-08-31 16:29:11 +03:00 committed by The Qt Project
parent 4b664eef64
commit aac24582c6

View 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();