diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2010-10-29 11:37:43 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2010-10-29 12:09:41 (GMT) |
commit | c4d715260bd0ed5f3b6d38a63a2659715342c90a (patch) | |
tree | 2c5f6cb9fc396789e7a14bfe6946b0a03f710464 /src/opengl/qgl.cpp | |
parent | bdc13bcc7b4d195d741142acce9b4e9b68c4d5e0 (diff) | |
download | Qt-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.cpp | 7 |
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; } |