src/gui/image/qpixmapdata.cpp
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
child 33 3e2da88830cd
--- a/src/gui/image/qpixmapdata.cpp	Tue Feb 02 00:43:10 2010 +0200
+++ b/src/gui/image/qpixmapdata.cpp	Wed Mar 31 11:06:36 2010 +0300
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 **
@@ -45,6 +45,7 @@
 #include <QtGui/qimagereader.h>
 #include <private/qgraphicssystem_p.h>
 #include <private/qapplication_p.h>
+#include <private/qimagepixmapcleanuphooks_p.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -80,6 +81,16 @@
 
 QPixmapData::~QPixmapData()
 {
+    // Sometimes the pixmap cleanup hooks will be called from derrived classes, which will
+    // then set is_cached to false. For example, on X11 QtOpenGL needs to delete the GLXPixmap
+    // or EGL Pixmap Surface for a given pixmap _before_ the native X11 pixmap is deleted,
+    // otherwise some drivers will leak the GL surface. In this case, QX11PixmapData will
+    // call the cleanup hooks itself before deleting the native pixmap and set is_cached to
+    // false.
+    if (is_cached) {
+        QImagePixmapCleanupHooks::executePixmapDataDestructionHooks(this);
+        is_cached = false;
+    }
 }
 
 QPixmapData *QPixmapData::createCompatiblePixmapData() const