src/gui/image/qpixmap_x11.cpp
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
child 22 79de32ba3296
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the QtGui module of the Qt Toolkit.
     7 ** This file is part of the QtGui module of the Qt Toolkit.
     8 **
     8 **
    66 #include <private/qpaintengine_x11_p.h>
    66 #include <private/qpaintengine_x11_p.h>
    67 #include <private/qt_x11_p.h>
    67 #include <private/qt_x11_p.h>
    68 #include "qx11info_x11.h"
    68 #include "qx11info_x11.h"
    69 #include <private/qdrawhelper_p.h>
    69 #include <private/qdrawhelper_p.h>
    70 #include <private/qimage_p.h>
    70 #include <private/qimage_p.h>
       
    71 #include <private/qimagepixmapcleanuphooks_p.h>
    71 
    72 
    72 #include <stdlib.h>
    73 #include <stdlib.h>
    73 
    74 
    74 #if defined(Q_CC_MIPS)
    75 #if defined(Q_CC_MIPS)
    75 #  define for if(0){}else for
    76 #  define for if(0){}else for
  1226     XFreeGC(X11->display, gc);
  1227     XFreeGC(X11->display, gc);
  1227 }
  1228 }
  1228 
  1229 
  1229 QX11PixmapData::~QX11PixmapData()
  1230 QX11PixmapData::~QX11PixmapData()
  1230 {
  1231 {
       
  1232     // Cleanup hooks have to be called before the handles are freed
       
  1233     if (is_cached) {
       
  1234         QImagePixmapCleanupHooks::executePixmapDataDestructionHooks(this);
       
  1235         is_cached = false;
       
  1236     }
       
  1237 
  1231     release();
  1238     release();
  1232 }
  1239 }
  1233 
  1240 
  1234 void QX11PixmapData::release()
  1241 void QX11PixmapData::release()
  1235 {
  1242 {
  1236     delete pengine;
  1243     delete pengine;
  1237     pengine = 0;
  1244     pengine = 0;
  1238 
  1245 
  1239     if (!X11)
  1246     if (!X11) {
       
  1247 #ifndef QT_NO_DEBUG
       
  1248         qWarning("~QX11PixmapData(): QPixmap objects must be destroyed before the QApplication"
       
  1249                  " object, otherwise the native pixmap object will be leaked.");
       
  1250 #endif
  1240         return;
  1251         return;
       
  1252     }
  1241 
  1253 
  1242     if (x11_mask) {
  1254     if (x11_mask) {
  1243 #ifndef QT_NO_XRENDER
  1255 #ifndef QT_NO_XRENDER
  1244         if (mask_picture)
  1256         if (mask_picture)
  1245             XRenderFreePicture(X11->display, mask_picture);
  1257             XRenderFreePicture(X11->display, mask_picture);
  1930         x11Data->h = h;
  1942         x11Data->h = h;
  1931         x11Data->is_null = (w <= 0 || h <= 0);
  1943         x11Data->is_null = (w <= 0 || h <= 0);
  1932         x11Data->hd = (Qt::HANDLE)XCreatePixmap(X11->display,
  1944         x11Data->hd = (Qt::HANDLE)XCreatePixmap(X11->display,
  1933                                                 RootWindow(X11->display, xinfo.screen()),
  1945                                                 RootWindow(X11->display, xinfo.screen()),
  1934                                                 w, h, d);
  1946                                                 w, h, d);
       
  1947         x11Data->setSerialNumber(++qt_pixmap_serial);
       
  1948 
  1935 #ifndef QT_NO_XRENDER
  1949 #ifndef QT_NO_XRENDER
  1936         if (X11->use_xrender) {
  1950         if (X11->use_xrender) {
  1937             XRenderPictFormat *format = x11Data->d == 32
  1951             XRenderPictFormat *format = x11Data->d == 32
  1938                                         ? XRenderFindStandardFormat(X11->display, PictStandardARGB32)
  1952                                         ? XRenderFindStandardFormat(X11->display, PictStandardARGB32)
  1939                                         : XRenderFindVisualFormat(X11->display, (Visual *) x11Data->xinfo.visual());
  1953                                         : XRenderFindVisualFormat(X11->display, (Visual *) x11Data->xinfo.visual());