src/gui/image/qpixmap_x11.cpp
branchRCL_3
changeset 8 3f74d0d4af4c
parent 4 3b1da2848fc7
child 14 c0432d11811c
--- a/src/gui/image/qpixmap_x11.cpp	Mon Mar 15 12:43:09 2010 +0200
+++ b/src/gui/image/qpixmap_x11.cpp	Thu Apr 08 14:19:33 2010 +0300
@@ -68,6 +68,7 @@
 #include "qx11info_x11.h"
 #include <private/qdrawhelper_p.h>
 #include <private/qimage_p.h>
+#include <private/qimagepixmapcleanuphooks_p.h>
 
 #include <stdlib.h>
 
@@ -1228,6 +1229,12 @@
 
 QX11PixmapData::~QX11PixmapData()
 {
+    // Cleanup hooks have to be called before the handles are freed
+    if (is_cached) {
+        QImagePixmapCleanupHooks::executePixmapDataDestructionHooks(this);
+        is_cached = false;
+    }
+
     release();
 }
 
@@ -1236,8 +1243,13 @@
     delete pengine;
     pengine = 0;
 
-    if (!X11)
+    if (!X11) {
+#ifndef QT_NO_DEBUG
+        qWarning("~QX11PixmapData(): QPixmap objects must be destroyed before the QApplication"
+                 " object, otherwise the native pixmap object will be leaked.");
+#endif
         return;
+    }
 
     if (x11_mask) {
 #ifndef QT_NO_XRENDER