path: root/src/opengl
diff options
authorSamuel Rødal <>2012-12-13 11:58:42 +0100
committerThe Qt Project <>2012-12-14 08:56:02 +0100
commit0ce317826f4fbef0e9297856322e1883e112a362 (patch)
tree9780adf73745e6d69062cf08f15c805a799e6023 /src/opengl
parent60bd2156f81b154a47c95989b0266944fd2f2859 (diff)
Fixed deadlock situation in QtOpenGL's texture management.
QGLTextureCache::remove(qint64 key) locks the QGLContextGroupList mutex before removing a texture. Removing the texture might cause the QGLShareContextScope construct to be invoked, which calls QGLContext::currentContext(), which will wrap a current QOpenGLContext in a newly created QGLContext. That also triggers the creation of a QGLContextGroup object, which will register itself with the QGLContextGroupList, an operation that again will lock the QGLContextGroupList mutex. To prevent this from deadlocking we make the mutex recursive. The whole QGLShareContextScope approach is really broken and should be replaced, but for now it's what we have in QtOpenGL (QtGui has the replacement QOpenGLSharedResource). Change-Id: Id1ff69035af3f31b690892c03f74748d052a278b Reviewed-by: Zeno Albisser <> Reviewed-by: Sean Harmer <>
Diffstat (limited to 'src/opengl')
1 files changed, 5 insertions, 0 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 69f4871c6b..9489762516 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1477,6 +1477,11 @@ bool operator!=(const QGLFormat& a, const QGLFormat& b)
struct QGLContextGroupList {
+ QGLContextGroupList()
+ : m_mutex(QMutex::Recursive)
+ {
+ }
void append(QGLContextGroup *group) {
QMutexLocker locker(&m_mutex);