From 8752faf0564bed86396b01529dc8ef5064150f4c Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Wed, 30 Nov 2011 14:41:39 +0200 Subject: Fix memory leaks in OpenVG and OpenGL resource pools Task-number: QTBUG-22743 Reviewed-by: Murray Read --- src/opengl/qgltexturepool.cpp | 6 ++---- src/openvg/qvgimagepool.cpp | 13 ++----------- src/openvg/qvgimagepool_p.h | 4 ---- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/opengl/qgltexturepool.cpp b/src/opengl/qgltexturepool.cpp index 9ad66f2..d19b1db 100644 --- a/src/opengl/qgltexturepool.cpp +++ b/src/opengl/qgltexturepool.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE Q_OPENGL_EXPORT extern QGLWidget* qt_gl_share_widget(); -static QGLTexturePool *qt_gl_texture_pool = 0; +Q_GLOBAL_STATIC(QGLTexturePool, qt_gl_texture_pool) class QGLTexturePoolPrivate { @@ -69,9 +69,7 @@ QGLTexturePool::~QGLTexturePool() QGLTexturePool *QGLTexturePool::instance() { - if (!qt_gl_texture_pool) - qt_gl_texture_pool = new QGLTexturePool(); - return qt_gl_texture_pool; + return qt_gl_texture_pool(); } GLuint QGLTexturePool::createTexture(GLenum target, diff --git a/src/openvg/qvgimagepool.cpp b/src/openvg/qvgimagepool.cpp index 3a187b0..cd1caf4 100644 --- a/src/openvg/qvgimagepool.cpp +++ b/src/openvg/qvgimagepool.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE -static QVGImagePool *qt_vg_image_pool = 0; +Q_GLOBAL_STATIC(QVGImagePool, qt_vg_image_pool) class QVGImagePoolPrivate { @@ -66,16 +66,7 @@ QVGImagePool::~QVGImagePool() QVGImagePool *QVGImagePool::instance() { - if (!qt_vg_image_pool) - qt_vg_image_pool = new QVGImagePool(); - return qt_vg_image_pool; -} - -void QVGImagePool::setImagePool(QVGImagePool *pool) -{ - if (qt_vg_image_pool != pool) - delete qt_vg_image_pool; - qt_vg_image_pool = pool; + return qt_vg_image_pool(); } VGImage QVGImagePool::createTemporaryImage(VGImageFormat format, diff --git a/src/openvg/qvgimagepool_p.h b/src/openvg/qvgimagepool_p.h index 07c57bf..e4fd4e1 100644 --- a/src/openvg/qvgimagepool_p.h +++ b/src/openvg/qvgimagepool_p.h @@ -69,10 +69,6 @@ public: static QVGImagePool *instance(); - // This function can be used from system-specific graphics system - // plugins to alter the image allocation strategy. - static void setImagePool(QVGImagePool *pool); - // Create a new VGImage from the pool with the specified parameters // that is not associated with a pixmap. The VGImage is returned to // the pool when releaseImage() is called. -- cgit v0.12