diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2010-11-08 09:05:28 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2010-11-08 12:03:51 (GMT) |
commit | ee958e086847e2131f9b746e5c6de4491ae1f44b (patch) | |
tree | 7396429debac0cc0074fd202c6af4bad25429c8b /src/opengl/qgl.cpp | |
parent | e600496d74c607f2316dd66f117a3d693769cca2 (diff) | |
download | Qt-ee958e086847e2131f9b746e5c6de4491ae1f44b.zip Qt-ee958e086847e2131f9b746e5c6de4491ae1f44b.tar.gz Qt-ee958e086847e2131f9b746e5c6de4491ae1f44b.tar.bz2 |
Prevented race condition on texture destruction.
When texture destruction was triggered from a different thread, we
posted a signal to the QGLSignalProxy. However, before the signal is
delivered the corresponding QGLContext might be destroyed in the main
thread. We need to post a signal to a QObject which is destroyed when
the QGLContext is destroyed instead, to prevent trying to access an
invalid QGLContext pointer.
Task-number: QT-4238
Reviewed-by: Gunnar Sletta
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r-- | src/opengl/qgl.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 84cfa97..ed9753e 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1642,12 +1642,23 @@ const QGLContext *qt_gl_transfer_context(const QGLContext *ctx) return 0; } +QGLContextPrivate::QGLContextPrivate(QGLContext *context) + : internal_context(false) + , q_ptr(context) +{ + group = new QGLContextGroup(context); + texture_destroyer = new QGLTextureDestroyer; + texture_destroyer->moveToThread(qApp->thread()); +} + QGLContextPrivate::~QGLContextPrivate() { if (!group->m_refs.deref()) { Q_ASSERT(group->context() == q_ptr); delete group; } + + delete texture_destroyer; } void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) |