diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2010-12-06 13:06:56 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2010-12-06 14:14:28 (GMT) |
commit | 9a63863d6f0c614c041c3d4b375bf88d93148ef7 (patch) | |
tree | 73397d058acc2051261f6550b46d97a31faa8195 /tests/auto/qimage | |
parent | 6ae84f1183e91c910ca92a55e37f8254ace805c0 (diff) | |
download | Qt-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/qimage')
-rw-r--r-- | tests/auto/qimage/tst_qimage.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index b446941..b2c59fc 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" |