summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);