summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2010-12-07 11:53:37 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2010-12-07 13:39:51 (GMT)
commiteac9e6a11e7727d8a749242f317362337ce89a1d (patch)
tree27e11cc2eec6863efdc5e86895c0cdbe3d4c5aba /src/gui/image
parent532115bcaa370af827a5cbad017b272842c5aacf (diff)
downloadQt-eac9e6a11e7727d8a749242f317362337ce89a1d.zip
Qt-eac9e6a11e7727d8a749242f317362337ce89a1d.tar.gz
Qt-eac9e6a11e7727d8a749242f317362337ce89a1d.tar.bz2
Prevent always deep-copying in QPixmap::toImage() for raster pixmaps.
Calling paintEngine() can cause a deep copy since it will indirectly call the bits() function. Since we don't want to create a paint engine if it doesn't exist we should access the QImageData paintEngine variable directly instead. Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qpixmap_raster.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp
index f080687..29bf5f5 100644
--- a/src/gui/image/qpixmap_raster.cpp
+++ b/src/gui/image/qpixmap_raster.cpp
@@ -50,6 +50,7 @@
#include "qimage.h"
#include <QBuffer>
#include <QImageReader>
+#include <private/qimage_p.h>
#include <private/qsimd_p.h>
#include <private/qwidget_p.h>
#include <private/qdrawhelper_p.h>
@@ -303,11 +304,13 @@ bool QRasterPixmapData::hasAlphaChannel() const
QImage QRasterPixmapData::toImage() const
{
- if (image.paintEngine()
- && image.paintEngine()->isActive()
- && image.paintEngine()->paintDevice() == &image)
- {
- return image.copy();
+ if (!image.isNull()) {
+ QImageData *data = const_cast<QImage &>(image).data_ptr();
+ if (data->paintEngine && data->paintEngine->isActive()
+ && data->paintEngine->paintDevice() == &image)
+ {
+ return image.copy();
+ }
}
return image;