summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopenglprogrambinarycache.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <[email protected]>2019-08-14 19:45:17 +0200
committerLaszlo Agocs <[email protected]>2019-08-17 16:26:44 +0200
commit257bd49c1f47ba5fca6930082fdcf108f9d24e3f (patch)
tree235e7228ae16ed5fd1571ef8ea39db391b35dd20 /src/gui/opengl/qopenglprogrambinarycache.cpp
parent6d3a4546934827955f0eb2b07a9928f82790ba37 (diff)
Guard with a mutex in QOpenGLProgramBinaryCache where needed
While there is likely no example of it in Qt itself, applications can use QOpenGLShaderProgram instances on different threads. These instances have nothing to do with each other but they do share a global cache object. This becomes problematic without proper synchronization. Change-Id: I80faf73f34af7e67349eee916bb3f216e22c07fd Fixes: QTBUG-77469 Reviewed-by: Christian Strømme <[email protected]>
Diffstat (limited to 'src/gui/opengl/qopenglprogrambinarycache.cpp')
-rw-r--r--src/gui/opengl/qopenglprogrambinarycache.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/gui/opengl/qopenglprogrambinarycache.cpp b/src/gui/opengl/qopenglprogrambinarycache.cpp
index af48cdacc79..40237b9935e 100644
--- a/src/gui/opengl/qopenglprogrambinarycache.cpp
+++ b/src/gui/opengl/qopenglprogrambinarycache.cpp
@@ -263,6 +263,7 @@ public:
bool QOpenGLProgramBinaryCache::load(const QByteArray &cacheKey, uint programId)
{
+ QMutexLocker lock(&m_mutex);
if (m_memCache.contains(cacheKey)) {
const MemCacheEntry *e = m_memCache[cacheKey];
return setProgramBinary(programId, e->format, e->blob.constData(), e->blob.size());
@@ -401,6 +402,7 @@ void QOpenGLProgramBinaryCache::save(const QByteArray &cacheKey, uint programId)
GLint outSize = 0;
#if defined(QT_OPENGL_ES_2)
if (context->isOpenGLES() && context->format().majorVersion() < 3) {
+ QMutexLocker lock(&m_mutex);
initializeProgramBinaryOES(context);
getProgramBinaryOES(programId, blobSize, &outSize, &blobFormat, p);
} else