From e2be53891fe218c9a1a63c2d385d149d2b1f982f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 7 Sep 2011 09:30:53 +0200 Subject: Fixed tst_QGL::destroyFBOAfterContext(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Properly free QOpenGLContext in QGLContext::reset(), if we own it. Change-Id: Ibd913283cf8b3b8a4dc6295a878a22a3989309a7 Reviewed-on: http://codereview.qt.nokia.com/4320 Reviewed-by: Qt Sanity Bot Reviewed-by: Jørgen Lind --- src/opengl/qgl_qpa.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/opengl/qgl_qpa.cpp') diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 46dfd54adf..afa2772a6f 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -148,7 +148,9 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) widget->winId();//make window } - delete d->guiGlContext; + if (d->ownContext) + delete d->guiGlContext; + d->ownContext = true; QOpenGLContext *shareGlContext = shareContext ? shareContext->d_func()->guiGlContext : 0; d->guiGlContext = new QOpenGLContext; d->guiGlContext->setFormat(winFormat); @@ -180,8 +182,13 @@ void QGLContext::reset() d->initDone = false; QGLContextGroup::removeShare(this); if (d->guiGlContext) { - d->guiGlContext->setQGLContextHandle(0,0); + if (d->ownContext) + delete d->guiGlContext; + else + d->guiGlContext->setQGLContextHandle(0,0); + d->guiGlContext = 0; } + d->ownContext = false; } void QGLContext::makeCurrent() @@ -385,6 +392,7 @@ QGLContext::QGLContext(QOpenGLContext *context) d->init(0, QGLFormat::fromSurfaceFormat(context->format())); d->guiGlContext = context; d->guiGlContext->setQGLContextHandle(this,qDeleteQGLContext); + d->ownContext = false; d->valid = context->isValid(); d->setupSharing(); } -- cgit v1.2.3