summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgl.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2010-10-29 11:37:43 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2010-10-29 12:09:41 (GMT)
commitc4d715260bd0ed5f3b6d38a63a2659715342c90a (patch)
tree2c5f6cb9fc396789e7a14bfe6946b0a03f710464 /src/opengl/qgl.cpp
parentbdc13bcc7b4d195d741142acce9b4e9b68c4d5e0 (diff)
downloadQt-c4d715260bd0ed5f3b6d38a63a2659715342c90a.zip
Qt-c4d715260bd0ed5f3b6d38a63a2659715342c90a.tar.gz
Qt-c4d715260bd0ed5f3b6d38a63a2659715342c90a.tar.bz2
Prevented threading related crash in OpenGL module.
If the last shallow copy of a QImage which is cached in the QGLTextureCache is destroyed in a thread at the same time as the QGLContext which the texture was initialized in is active in a different thread, the QImage thread incorrectly tries to make the context active in two threads at once. To prevent this from happening it's best to always do the texture clean-up in the main thread. Task-number: QT-4238 Reviewed-by: Eskil Abrahamsen Blomfeldt
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r--src/opengl/qgl.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index dbd295f..84cfa97 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -127,7 +127,12 @@ Q_GLOBAL_STATIC(QGLDefaultOverlayFormat, defaultOverlayFormatInstance)
Q_GLOBAL_STATIC(QGLSignalProxy, theSignalProxy)
QGLSignalProxy *QGLSignalProxy::instance()
{
- return theSignalProxy();
+ QGLSignalProxy *proxy = theSignalProxy();
+ if (proxy && proxy->thread() != qApp->thread()) {
+ if (proxy->thread() == QThread::currentThread())
+ proxy->moveToThread(qApp->thread());
+ }
+ return proxy;
}