Skip to content

Commit

Permalink
Fix possible crash in QSGContext::invalidate()
Browse files Browse the repository at this point in the history
In some cases QSGContext::invalidate() was called without any current
GL context when the render thread was terminated.

Change-Id: Ia5295c89fe13f2473115c736e328e386d6d4d183
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
  • Loading branch information
Yoann Lopes authored and Qt by Nokia committed Mar 19, 2012
1 parent 3a3515b commit 5901943
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/quick/items/qquickwindowmanager.cpp
Expand Up @@ -228,7 +228,7 @@ public slots:
private:
void handleAddedWindows();
void handleAddedWindow(QQuickCanvas *canvas);
void handleRemovedWindows();
void handleRemovedWindows(bool clearGLContext = true);

QSGContext *sg;
QOpenGLContext *gl;
Expand Down Expand Up @@ -475,7 +475,7 @@ void QQuickRenderThreadSingleContextWindowManager::hide(QQuickCanvas *canvas)
/*!
Called on Render Thread
*/
void QQuickRenderThreadSingleContextWindowManager::handleRemovedWindows()
void QQuickRenderThreadSingleContextWindowManager::handleRemovedWindows(bool clearGLContext)
{
#ifdef THREAD_DEBUG
printf(" RenderThread: about to remove %d\n", m_removed_windows.size());
Expand All @@ -496,7 +496,7 @@ void QQuickRenderThreadSingleContextWindowManager::handleRemovedWindows()
// If a window is removed because it has been hidden it will take with it
// the gl context (at least on Mac) if bound, so disconnect the gl context
// from anything
if (removedAnything)
if (removedAnything && clearGLContext)
gl->doneCurrent();
}

Expand Down Expand Up @@ -755,7 +755,7 @@ void QQuickRenderThreadSingleContextWindowManager::run()
#endif

m_removed_windows << m_rendered_windows.keys();
handleRemovedWindows();
handleRemovedWindows(false);

sg->invalidate();

Expand Down

0 comments on commit 5901943

Please sign in to comment.