diff options
author | Liang Jian <jianliang79@gmail.com> | 2014-03-27 17:59:59 +0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-27 17:51:21 +0100 |
commit | 666c25c089acf7fcc9e9a6b7665074c6286d604e (patch) | |
tree | ac37b417aa241e83ef8f01f8bfe28ea3781689e8 /src/gui | |
parent | dd453adbe7611900ff20ee77141229c01fe1bc98 (diff) |
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 <laszlo.agocs@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qopenglcontext_p.h | 1 |
1 files changed, 1 insertions, 0 deletions
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 <typename T> T *value(QOpenGLContext *context) { QOpenGLContextGroup *group = context->shareGroup(); + QMutexLocker locker(&group->d_func()->m_mutex); T *resource = static_cast<T *>(group->d_func()->m_resources.value(this, 0)); if (!resource) { resource = new T(context); |