summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Poulain <benjamin.poulain@nokia.com>2010-10-08 14:21:10 +0200
committerJesper Thomschutz <jesper.thomschutz@nokia.com>2010-10-10 19:52:34 +0200
commit6f596b07a7c035b36bc1005a83b283057669e4ac (patch)
treea6b6902cae3d98e0ee9099741496fb7fa45a4bef
parentdc5299e1a59e066e4b804c081114edaa8b104438 (diff)
Avoid in-place convertion of images with multiple references
The decoding from image reader was assuming the image reader do not keep the image internally. This is not true for the GIF plugins because the previous image can be used to compose the current image. This was causing crash on ARM because the 16 bits color depth causes the image memory to be reduce by half. When the plugin was accessing the memory, it assumes the images has not changed and is on 32 bits. This patch disable the in-place conversion if a detach is required. Regular conversion is the correct solution in this case, and it can also be made faster by converting while copying. Reviewed-by: Andreas Kling (cherry picked from commit 4d974ff0a748b22e668a4cb7ef38101122c85b3b)
-rw-r--r--src/gui/image/qimage.cpp4
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp13
2 files changed, 16 insertions, 1 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index ac148eec31..1157b93236 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -6607,6 +6607,10 @@ bool QImageData::convertInPlace(QImage::Format newFormat, Qt::ImageConversionFla
if (format == newFormat)
return true;
+ // No in-place conversion if we have to detach
+ if (ref > 1)
+ return false;
+
const InPlace_Image_Converter *const converterPtr = &inplace_converter_map[format][newFormat];
InPlace_Image_Converter converter = *converterPtr;
if (converter)
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 8005ec5d50..24cbb21ae4 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -179,6 +179,7 @@ private slots:
void fromImageReader_data();
void fromImageReader();
+ void fromImageReaderAnimatedGif_data();
void fromImageReaderAnimatedGif();
void preserveDepth();
@@ -1605,6 +1606,8 @@ void tst_QPixmap::fromImageReader_data()
QTest::newRow("designer_indexed8_no_alpha.gif") << prefix + "/designer_indexed8_no_alpha.gif";
QTest::newRow("designer_indexed8_with_alpha.gif") << prefix + "/designer_indexed8_with_alpha.gif";
QTest::newRow("designer_rgb32.jpg") << prefix + "/designer_rgb32.jpg";
+ QTest::newRow("designer_indexed8_with_alpha_animated") << prefix + "/designer_indexed8_with_alpha_animated.gif";
+ QTest::newRow("designer_indexed8_with_alpha_animated") << prefix + "/designer_indexed8_no_alpha_animated.gif";
}
void tst_QPixmap::fromImageReader()
@@ -1621,14 +1624,22 @@ void tst_QPixmap::fromImageReader()
QVERIFY(pixmapsAreEqual(&pixmapWithCopy, &directLoadingPixmap));
}
+void tst_QPixmap::fromImageReaderAnimatedGif_data()
+{
+ QTest::addColumn<QString>("imagePath");
+ QTest::newRow("gif with alpha") << QString::fromLatin1("/designer_indexed8_with_alpha_animated.gif");
+ QTest::newRow("gif without alpha") << QString::fromLatin1("/designer_indexed8_no_alpha_animated.gif");
+}
+
void tst_QPixmap::fromImageReaderAnimatedGif()
{
+ QFETCH(QString, imagePath);
#ifdef Q_OS_SYMBIAN
const QString prefix = QLatin1String(SRCDIR) + "loadFromData";
#else
const QString prefix = QLatin1String(SRCDIR) + "/loadFromData";
#endif
- const QString path = prefix + QString::fromLatin1("/designer_indexed8_with_alpha_animated.gif");
+ const QString path = prefix + imagePath;
QImageReader referenceReader(path);
QImageReader pixmapReader(path);