From bdd7372edf4cb64177e97ef6087a6ec2a4903225 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 23 Apr 2010 17:21:39 +0200 Subject: Don't leak objects if QX11GLSharedContexts is instanciated twice If two threads call the Q_GLOBAL_STATIC accessor at the same time, two QX11GLSharedContexts objects can be created with one being destroyed. Reviewed-By: TrustMe --- src/opengl/qpixmapdata_x11gl_egl.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/opengl/qpixmapdata_x11gl_egl.cpp b/src/opengl/qpixmapdata_x11gl_egl.cpp index e0c274a..2c11a0b 100644 --- a/src/opengl/qpixmapdata_x11gl_egl.cpp +++ b/src/opengl/qpixmapdata_x11gl_egl.cpp @@ -74,7 +74,6 @@ public: EGLint rgbConfigId; EGLint argbConfigId; - do { EGLConfig rgbConfig = QEgl::defaultConfig(QInternal::Pixmap, QEgl::OpenGL, QEgl::Renderable); EGLConfig argbConfig = QEgl::defaultConfig(QInternal::Pixmap, QEgl::OpenGL, @@ -138,6 +137,7 @@ public: valid = argbContext->makeCurrent(argbPixmapSurface); argbContext->doneCurrent(); eglDestroySurface(QEgl::display(), argbPixmapSurface); + argbPixmapData->gl_surface = 0; } if (!valid) { @@ -150,7 +150,6 @@ public: QGLTextureCache::instance(); } while(0); - if (!valid) cleanup(); else @@ -158,6 +157,10 @@ public: } + ~QX11GLSharedContexts() { + cleanup(); + } + void cleanup() { if (sharedQGLContext) { delete sharedQGLContext; @@ -222,8 +225,8 @@ bool QX11GLPixmapData::hasX11GLPixmaps() if (checkedForX11GLPixmaps) return haveX11GLPixmaps; + haveX11GLPixmaps = qt_x11gl_share_contexts()->isValid(); checkedForX11GLPixmaps = true; - haveX11GLPixmaps = sharedContexts()->isValid(); return haveX11GLPixmaps; } -- cgit v0.12