QPixmap::fromImage() should detach when changing QImage format

When QPixmap::fromImage() detects an ARGB32 image with only opaque
pixels it will do a conversion where it only changes the advertised
format of the image. This conversion was lacking a check to see if it
the QImage was shared before doing so, which this patch adds.

Task-number: QTBUG-40282
Change-Id: I3acf221b76735637cef04c2104a33f87e5f09d54
Reviewed-by: Andreas Löw <andreas@code-and-web.de>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Allan Sandfeld Jensen 2014-07-22 13:45:58 +02:00
parent 4cedc55327
commit b0d0a2680a

View File

@ -343,6 +343,7 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC
if (format == QImage::Format_RGB32 && (sourceImage.format() == QImage::Format_ARGB32
|| sourceImage.format() == QImage::Format_ARGB32_Premultiplied))
{
inPlace = inPlace && sourceImage.isDetached();
image = sourceImage;
if (!inPlace)
image.detach();