From 6385a182f0f93820c96cf274e50a56492491ee10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 26 Nov 2012 12:57:09 +0100 Subject: Added explicit threading API to QtOpenGL. Since QtOpenGL/QGLContext is implemented in terms of QtGui/QOpenGLContext which has stricter requirements about how it's supposed to be used, we need to apply these requirements to QGLContext as well. This change adds QGLContext::moveToThread(QThread *) and documents it as a necessity for making a context current on another thread. Also introduces QGLPixelbuffer::context() to access the QGLContext of a pixelbuffer, and made QGLWidget::context() return a non-const QGLContext, since there's no good reason why it shouldn't, and it leads to less const_cast clutter. We could have introduced a backdoor in QOpenGLContext instead, making it loosen its requirements, but that would have made it harder / impossible to fully support threaded OpenGL in all the platforms. Task-number: QTBUG-22560 Change-Id: Ibb6f65f342e7c963e80cc42ab5664c5f1cab30b0 Reviewed-by: Friedemann Kleint Reviewed-by: Gunnar Sletta --- src/opengl/qgl_qpa.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/opengl/qgl_qpa.cpp') diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index f52beceaae..ba07f6121c 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -186,9 +186,14 @@ void QGLContext::reset() d->initDone = false; QGLContextGroup::removeShare(this); if (d->guiGlContext) { - if (d->ownContext) - delete d->guiGlContext; - else + if (QOpenGLContext::currentContext() == d->guiGlContext) + doneCurrent(); + if (d->ownContext) { + if (d->guiGlContext->thread() == QThread::currentThread()) + delete d->guiGlContext; + else + d->guiGlContext->deleteLater(); + } else d->guiGlContext->setQGLContextHandle(0,0); d->guiGlContext = 0; } -- cgit v1.2.3