From 666c25c089acf7fcc9e9a6b7665074c6286d604e Mon Sep 17 00:00:00 2001 From: Liang Jian Date: Thu, 27 Mar 2014 17:59:59 +0800 Subject: Fix race condition in QOpenGLMultiGroupSharedResource In QOpenGLMultiGroupSharedResource::value(), the m_resources memeber of opengl context group will be checked and may be inserted a new value. This function may be called from different threads with the same opengl context group object: Think about that OpenGL context A and B are shared, they live in different thread, and in each thread we call QOpenGLContext::functions() to the context, that may cause the race I mentioned above. So I put a QMutexLocker to prevent race condition. Change-Id: I101a28f46b2af72b3094a9945880efeb3563482a Reviewed-by: Laszlo Agocs --- src/gui/kernel/qopenglcontext_p.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index 07729e0e73..23c13b2e24 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -171,6 +171,7 @@ public: template T *value(QOpenGLContext *context) { QOpenGLContextGroup *group = context->shareGroup(); + QMutexLocker locker(&group->d_func()->m_mutex); T *resource = static_cast(group->d_func()->m_resources.value(this, 0)); if (!resource) { resource = new T(context); -- cgit v1.2.3