summaryrefslogtreecommitdiffstats
path: root/tests/auto/qimage
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2010-12-06 14:06:56 +0100
committerSamuel Rødal <samuel.rodal@nokia.com>2010-12-06 15:14:28 +0100
commit9a63863d6f0c614c041c3d4b375bf88d93148ef7 (patch)
tree73397d058acc2051261f6550b46d97a31faa8195 /tests/auto/qimage
parent6ae84f1183e91c910ca92a55e37f8254ace805c0 (diff)
Make sure to do a deep copy of a QImage when it's being painted on.
Not doing so can produce some hard-to-track-down bugs in the app. Task-number: QTBUG-15749 Reviewed-by: Gunnar Sletta
Diffstat (limited to 'tests/auto/qimage')
-rw-r--r--tests/auto/qimage/tst_qimage.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp
index b4469416c5..b2c59fc698 100644
--- a/tests/auto/qimage/tst_qimage.cpp
+++ b/tests/auto/qimage/tst_qimage.cpp
@@ -142,6 +142,8 @@ private slots:
void rgbSwapped_data();
void rgbSwapped();
+
+ void deepCopyWhenPaintingActive();
};
tst_QImage::tst_QImage()
@@ -1886,5 +1888,19 @@ void tst_QImage::rgbSwapped()
QCOMPARE(memcmp(image.constBits(), imageSwappedTwice.constBits(), image.numBytes()), 0);
}
+void tst_QImage::deepCopyWhenPaintingActive()
+{
+ QImage image(64, 64, QImage::Format_ARGB32_Premultiplied);
+ image.fill(0);
+
+ QPainter painter(&image);
+ QImage copy = image;
+
+ painter.setBrush(Qt::black);
+ painter.drawEllipse(image.rect());
+
+ QVERIFY(copy != image);
+}
+
QTEST_MAIN(tst_QImage)
#include "tst_qimage.moc"