diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2009-11-27 09:42:47 (GMT) |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2009-11-27 09:46:43 (GMT) |
commit | 583b1529894aca5e9ffa353f0547dfb4b8b0ab21 (patch) | |
tree | f151b7fd25bc347e344b3c11ce95e3ab5be3a40e /src/gui/image/qimagepixmapcleanuphooks.cpp | |
parent | aa911fcc8cae12c92941e21a02b7621d4e4bf118 (diff) | |
download | Qt-583b1529894aca5e9ffa353f0547dfb4b8b0ab21.zip Qt-583b1529894aca5e9ffa353f0547dfb4b8b0ab21.tar.gz Qt-583b1529894aca5e9ffa353f0547dfb4b8b0ab21.tar.bz2 |
Fixed memory leak in QImagePixmapCleanupHooks.
The QImagePixmapCleanupHooks instance was never deleted. Fixed by making
it a Q_GLOBAL_STATIC.
Task-number: QTBUG-6116
Reviewed-by: Trond
Diffstat (limited to 'src/gui/image/qimagepixmapcleanuphooks.cpp')
-rw-r--r-- | src/gui/image/qimagepixmapcleanuphooks.cpp | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp index 35322e9..650075b 100644 --- a/src/gui/image/qimagepixmapcleanuphooks.cpp +++ b/src/gui/image/qimagepixmapcleanuphooks.cpp @@ -55,20 +55,11 @@ Q_GUI_EXPORT _qt_pixmap_cleanup_hook_64 qt_pixmap_cleanup_hook_64 = 0; Q_GUI_EXPORT _qt_image_cleanup_hook qt_image_cleanup_hook = 0; Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64 = 0; - -QImagePixmapCleanupHooks* qt_image_and_pixmap_cleanup_hooks = 0; - - -QImagePixmapCleanupHooks::QImagePixmapCleanupHooks() -{ - qt_image_and_pixmap_cleanup_hooks = this; -} +Q_GLOBAL_STATIC(QImagePixmapCleanupHooks, qt_image_and_pixmap_cleanup_hooks) QImagePixmapCleanupHooks *QImagePixmapCleanupHooks::instance() { - if (!qt_image_and_pixmap_cleanup_hooks) - qt_image_and_pixmap_cleanup_hooks = new QImagePixmapCleanupHooks; - return qt_image_and_pixmap_cleanup_hooks; + return qt_image_and_pixmap_cleanup_hooks(); } void QImagePixmapCleanupHooks::addPixmapModificationHook(_qt_pixmap_cleanup_hook_pm hook) @@ -105,9 +96,8 @@ void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook) void QImagePixmapCleanupHooks::executePixmapModificationHooks(QPixmap* pm) { - Q_ASSERT(qt_image_and_pixmap_cleanup_hooks); - for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapModificationHooks.count(); ++i) - qt_image_and_pixmap_cleanup_hooks->pixmapModificationHooks[i](pm); + for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks()->pixmapModificationHooks.count(); ++i) + qt_image_and_pixmap_cleanup_hooks()->pixmapModificationHooks[i](pm); if (qt_pixmap_cleanup_hook_64) qt_pixmap_cleanup_hook_64(pm->cacheKey()); @@ -115,9 +105,8 @@ void QImagePixmapCleanupHooks::executePixmapModificationHooks(QPixmap* pm) void QImagePixmapCleanupHooks::executePixmapDestructionHooks(QPixmap* pm) { - Q_ASSERT(qt_image_and_pixmap_cleanup_hooks); - for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapDestructionHooks.count(); ++i) - qt_image_and_pixmap_cleanup_hooks->pixmapDestructionHooks[i](pm); + for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks()->pixmapDestructionHooks.count(); ++i) + qt_image_and_pixmap_cleanup_hooks()->pixmapDestructionHooks[i](pm); if (qt_pixmap_cleanup_hook_64) qt_pixmap_cleanup_hook_64(pm->cacheKey()); @@ -125,9 +114,8 @@ void QImagePixmapCleanupHooks::executePixmapDestructionHooks(QPixmap* pm) void QImagePixmapCleanupHooks::executeImageHooks(qint64 key) { - Q_ASSERT(qt_image_and_pixmap_cleanup_hooks); - for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->imageHooks.count(); ++i) - qt_image_and_pixmap_cleanup_hooks->imageHooks[i](key); + for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks()->imageHooks.count(); ++i) + qt_image_and_pixmap_cleanup_hooks()->imageHooks[i](key); if (qt_image_cleanup_hook_64) qt_image_cleanup_hook_64(key); |