From 295786d946aed262b01f5941dcde72d68781f6c1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 5 May 2014 17:52:47 +0200 Subject: Avoid corruption in Q(Open)GLFunctions when used on multiple threads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using Q(Open)GLFunctions concurrently on multiple threads had some issues due to incorrect synchronization: The m_groups list in the QOpenGLMultiGroupSharedResource, in which the Q(Open)GLFunctions instance is stored, became corrupted under certain scenarios, for example in the tst_qglthreads autotest and any two threads that happen to enter an initializeOpenGLFunctions() or QOpenGLContext::functions() call concurrently. Locking in value() has been introduced in 666c25c089acf7fcc9e9a6b7665074c6286d604e to fix such issues, however using the context group's mutex is not enough: that still allows two threads using two contexts with a different context group to concurrently enter insert(). Instead, the MultiGroupSharedResource has to have its own mutex to protect its own member variables. Task-number: QTBUG-38771 Change-Id: If01c44c2084b95e487bc9146576ca180ed8044da Reviewed-by: Jørgen Lind --- src/gui/kernel/qopenglcontext.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui/kernel/qopenglcontext.cpp') diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 1af5c09fd2..be592153d2 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -1345,7 +1345,8 @@ void QOpenGLSharedResourceGuard::freeResource(QOpenGLContext *context) QOpenGLMultiGroupSharedResource instance. */ QOpenGLMultiGroupSharedResource::QOpenGLMultiGroupSharedResource() - : active(0) + : active(0), + m_mutex(QMutex::Recursive) { #ifdef QT_GL_CONTEXT_RESOURCE_DEBUG qDebug("Creating context group resource object %p.", this); -- cgit v1.2.3