summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpixmap
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2010-12-06 13:06:56 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2010-12-06 14:14:28 (GMT)
commit9a63863d6f0c614c041c3d4b375bf88d93148ef7 (patch)
tree73397d058acc2051261f6550b46d97a31faa8195 /tests/auto/qpixmap
parent6ae84f1183e91c910ca92a55e37f8254ace805c0 (diff)
downloadQt-9a63863d6f0c614c041c3d4b375bf88d93148ef7.zip
Qt-9a63863d6f0c614c041c3d4b375bf88d93148ef7.tar.gz
Qt-9a63863d6f0c614c041c3d4b375bf88d93148ef7.tar.bz2
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/qpixmap')
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 51e6cf5..d5267b5 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -185,6 +185,8 @@ private slots:
void preserveDepth();
void splash_crash();
+ void toImageDeepCopy();
+
void loadAsBitmapOrPixmap();
};
@@ -1751,6 +1753,21 @@ void tst_QPixmap::loadAsBitmapOrPixmap()
QVERIFY(bitmap.isQBitmap());
}
+void tst_QPixmap::toImageDeepCopy()
+{
+ QPixmap pixmap(64, 64);
+ pixmap.fill(Qt::white);
+
+ QPainter painter(&pixmap);
+ QImage first = pixmap.toImage();
+
+ painter.setBrush(Qt::black);
+ painter.drawEllipse(pixmap.rect());
+
+ QImage second = pixmap.toImage();
+
+ QVERIFY(first != second);
+}
QTEST_MAIN(tst_QPixmap)