summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJani Hautakangas <jani.hautakangas@nokia.com>2011-11-30 12:41:39 (GMT)
committerJani Hautakangas <jani.hautakangas@nokia.com>2011-11-30 13:23:47 (GMT)
commit8752faf0564bed86396b01529dc8ef5064150f4c (patch)
treec398d5b2b7ad4af203ffeef1f89a994e54804ac8
parent9a5fb6bd5f0fb3b37897bf722e4cc1673309623c (diff)
downloadQt-8752faf0564bed86396b01529dc8ef5064150f4c.zip
Qt-8752faf0564bed86396b01529dc8ef5064150f4c.tar.gz
Qt-8752faf0564bed86396b01529dc8ef5064150f4c.tar.bz2
Fix memory leaks in OpenVG and OpenGL resource pools
Task-number: QTBUG-22743 Reviewed-by: Murray Read
-rw-r--r--src/opengl/qgltexturepool.cpp6
-rw-r--r--src/openvg/qvgimagepool.cpp13
-rw-r--r--src/openvg/qvgimagepool_p.h4
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.