summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpixmap_raster.cpp
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2012-07-13 12:42:18 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-16 10:09:15 +0200
commitc44d7eedfdfa80598c877bd2a708a8f126c25fc4 (patch)
tree0ca776340b111368f2a95feb762966dc20190a34 /src/gui/image/qpixmap_raster.cpp
parentcd1351401ffdfe5e6097b4b41a632655f9fa6e03 (diff)
Fix crash in QPixmap::fromImage() when memory is low.
Task-number: QTBUG-26451 Change-Id: I7149edb1b03d7bcd4e90f369a1ac99b25ab262b9 Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/gui/image/qpixmap_raster.cpp')
-rw-r--r--src/gui/image/qpixmap_raster.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp
index 260deb4482..d34596e76f 100644
--- a/src/gui/image/qpixmap_raster.cpp
+++ b/src/gui/image/qpixmap_raster.cpp
@@ -318,15 +318,6 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC
} else if ((flags & Qt::NoOpaqueDetection) == 0
&& !const_cast<QImage &>(sourceImage).data_ptr()->checkForAlphaPixels())
{
- // image has alpha format but is really opaque, so try to do a
- // more efficient conversion
- if (sourceImage.format() == QImage::Format_ARGB32
- || sourceImage.format() == QImage::Format_ARGB32_Premultiplied)
- {
- if (!inPlace)
- sourceImage.detach();
- sourceImage.d->format = QImage::Format_RGB32;
- }
format = opaqueFormat;
} else {
format = alphaFormat;
@@ -334,7 +325,17 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC
}
}
- if (inPlace && sourceImage.d->convertInPlace(format, flags)) {
+ // image has alpha format but is really opaque, so try to do a
+ // more efficient conversion
+ if (format == QImage::Format_RGB32 && (sourceImage.format() == QImage::Format_ARGB32
+ || sourceImage.format() == QImage::Format_ARGB32_Premultiplied))
+ {
+ image = sourceImage;
+ if (!inPlace)
+ image.detach();
+ if (image.d)
+ image.d->format = QImage::Format_RGB32;
+ } else if (inPlace && sourceImage.d->convertInPlace(format, flags)) {
image = sourceImage;
} else {
image = sourceImage.convertToFormat(format);