diff options
author | Gunnar Sletta <[email protected]> | 2014-08-14 06:38:12 +0000 |
---|---|---|
committer | Gunnar Sletta <[email protected]> | 2014-08-14 11:20:20 +0200 |
commit | 68ac67af2346c89ea2b482bbcf6c3636d9c31e66 (patch) | |
tree | ea3e78ed01dced2b054e576afc29555e961c7aee /src/quick/scenegraph/qsgthreadedrenderloop.cpp | |
parent | 4422be44ae3bd159e6f68ff22330196f6666368c (diff) |
Fix potential deadlook in threaded renderloop.
Change-Id: I415e632aa4e584c8fca745581f25a676db0eae42
Reviewed-by: Giulio Camuffo <[email protected]>
Reviewed-by: Robin Burchell <[email protected]>
Diffstat (limited to 'src/quick/scenegraph/qsgthreadedrenderloop.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgthreadedrenderloop.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index 296050ec2f..c17eb916ae 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -1116,6 +1116,18 @@ void QSGThreadedRenderLoop::releaseResources(QQuickWindow *window, bool inDestru w->thread->waitCondition.wait(&w->thread->mutex); delete fallback; + + // Avoid a shutdown race condition. + // If SG is invalidated and 'active' becomes false, the thread's run() + // method will exit. handleExposure() relies on QThread::isRunning() (because it + // potentially needs to start the thread again) and our mutex cannot be used to + // track the thread stopping, so we wait a few nanoseconds extra so the thread + // can exit properly. + if (!w->thread->active) { + QSG_GUI_DEBUG(w->window, " - waiting for render thread to exit"); + w->thread->wait(); + QSG_GUI_DEBUG(w->window, " - render thread finished"); + } } w->thread->mutex.unlock(); } |