From a7965832a46af1c9d58c6aca38084b6436f48302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 26 Nov 2012 16:39:40 +0100 Subject: Fixed crash in tst_qglthreads. QGLTextureCache has a read write locker to protect texture lookups. However, even calling QCache::object() might modify the cache, causing race conditions, since it modifies the priority order of the objects in the cache. Therefore, we need to protect it with a QWriteLocker instead of a QReadLocker. Task-number: QTBUG-22560 Change-Id: I46fffc624ace27e25fb100f865e1df0a19b9093d Reviewed-by: Gabriel de Dietrich (cherry picked from commit 6633dbbac49f4ce8a89b67090fdffaa8c8126eb5) Reviewed-by: Gunnar Sletta Reviewed-by: Lars Knoll --- src/opengl/qgl_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index b5d17e8..5fe6678 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -696,7 +696,8 @@ int QGLTextureCache::maxCost() QGLTexture* QGLTextureCache::getTexture(QGLContext *ctx, qint64 key) { - QReadLocker locker(&m_lock); + // Can't be a QReadLocker since QCache::object() modifies the cache (reprioritizes the object) + QWriteLocker locker(&m_lock); const QGLTextureCacheKey cacheKey = {key, QGLContextPrivate::contextGroup(ctx)}; return m_cache.object(cacheKey); } -- cgit v0.12