diff options
author | David Fries <David@Fries.net> | 2014-07-17 15:23:26 -0500 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-08-05 17:30:03 +0200 |
commit | 3a347a4e70e5a10ee92dd2578316c926a399e894 (patch) | |
tree | 119daca696d138c5fea7489fa0f54fa98abad0cf /src/opengl | |
parent | e1fed5dc3156f32f22d78dc57fa5ab8fcedaa804 (diff) | |
download | qtbase-3a347a4e70e5a10ee92dd2578316c926a399e894.tar.gz |
OpenGL: destroy QGLContext allocated by QGLContext::fromOpenGLContext
QGLContext already uses ownContext to identify when it "owns" QOpenGLContext
and will delete QOpenGLContext when needed. In the other way
QGLContext::fromOpenGLContext creates a QGLContext for QOpenGLContext, and is
now using qGLContextDeleteFunction to identify if QOpenGLContext "owns"
QGLContext by QGLContext only passing a delete function when QOpenGLContext
should delete QGLContext, and by QOpenGLContext calling deleteQGLContext() from
destory() to do the destruction avoiding the previous leak and sometimes crash
on exit.
Change-Id: I65e791776e99b456e4d0c70fc5b5cdb33c975893
Task-number: QTBUG-40286
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qgl_p.h | 1 | ||||
-rw-r--r-- | src/opengl/qgl_qpa.cpp | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 22fc3f4ad0..ac4b6d2acc 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -242,6 +242,7 @@ public: void swapRegion(const QRegion ®ion); QOpenGLContext *guiGlContext; + // true if QGLContext owns the QOpenGLContext (for who deletes who) bool ownContext; void setupSharing(); diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 90ba0e7f5a..6194f82922 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -135,7 +135,7 @@ bool QGLFormat::hasOpenGL() ->hasCapability(QPlatformIntegration::OpenGL); } -void qDeleteQGLContext(void *handle) +static void qDeleteQGLContext(void *handle) { QGLContext *context = static_cast<QGLContext *>(handle); delete context; @@ -177,7 +177,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) d->valid = d->guiGlContext->create(); if (d->valid) - d->guiGlContext->setQGLContextHandle(this,qDeleteQGLContext); + d->guiGlContext->setQGLContextHandle(this, 0); d->glFormat = QGLFormat::fromSurfaceFormat(d->guiGlContext->format()); d->setupSharing(); |