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>
This commit is contained in:
parent
dd453adbe7
commit
666c25c089
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user