summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrond Kjernåsen <trond@trolltech.com>2010-01-29 16:14:00 +0100
committerTrond Kjernåsen <trond@trolltech.com>2010-01-29 16:17:20 +0100
commit4a5e81f5320daa82352b13e670718998b0d2d23b (patch)
treeb803d629789df6debe937db0f681502d78aa336f
parent9e95ce2a68ef167e17dccc5789cbf3bf74712280 (diff)
downloadqt4-tools-4a5e81f5320daa82352b13e670718998b0d2d23b.tar.gz
Fixed a crash when QPixmaps are destroyed after the ~QApplication.
Destroying QPixmaps after the QApp destructor will leak native pixmap objects on X11, and it's a general rule that all GUI objects must be destroyed before the QApp destuctor is called. Task-number: QTBUG-7746 Reviewed-by: Kim
-rw-r--r--src/gui/image/qpixmap_x11.cpp7
-rw-r--r--src/gui/painting/qpainter.cpp4
2 files changed, 8 insertions, 3 deletions
diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp
index 169a2ece26..e1e8a0db5e 100644
--- a/src/gui/image/qpixmap_x11.cpp
+++ b/src/gui/image/qpixmap_x11.cpp
@@ -1243,8 +1243,13 @@ void QX11PixmapData::release()
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
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index cde6a2d6c9..bf12c6b584 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -7509,7 +7509,7 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset)
return widgetPrivate->redirected(offset);
}
- if (*globalRedirectionAtomic() == 0)
+ if (!globalRedirectionAtomic() || *globalRedirectionAtomic() == 0)
return 0;
QMutexLocker locker(globalRedirectionsMutex());
@@ -7529,7 +7529,7 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset)
void qt_painter_removePaintDevice(QPaintDevice *dev)
{
- if (*globalRedirectionAtomic() == 0)
+ if (!globalRedirectionAtomic() || *globalRedirectionAtomic() == 0)
return;
QMutex *mutex = 0;