From 0ce317826f4fbef0e9297856322e1883e112a362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 13 Dec 2012 11:58:42 +0100 Subject: [PATCH] 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 --- src/opengl/qgl.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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); m_list.append(group);