summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpainter/tst_qpainter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qpainter/tst_qpainter.cpp')
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 45f5c3e..ff9bf1c 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -49,6 +49,7 @@
#include <qfontmetrics.h>
#include <qbitmap.h>
#include <qimage.h>
+#include <qthread.h>
#include <limits.h>
#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
#include <qprinter.h>
@@ -254,6 +255,8 @@ private slots:
void drawPointScaled();
+ void QTBUG14614_gradientCacheRaceCondition();
+
private:
void fillData();
void setPenColor(QPainter& p);
@@ -4543,6 +4546,36 @@ void tst_QPainter::drawPointScaled()
QCOMPARE(image.pixel(16, 16), 0xffff0000);
}
+class GradientProducer : public QThread
+{
+protected:
+ void run();
+};
+
+void GradientProducer::run()
+{
+ QImage image(1, 1, QImage::Format_RGB32);
+ QPainter p(&image);
+
+ for (int i = 0; i < 1000; ++i) {
+ QLinearGradient g;
+ g.setColorAt(0, QColor(i % 256, 0, 0));
+ g.setColorAt(1, Qt::white);
+
+ p.fillRect(image.rect(), g);
+ }
+}
+
+void tst_QPainter::QTBUG14614_gradientCacheRaceCondition()
+{
+ const int threadCount = 16;
+ GradientProducer producers[threadCount];
+ for (int i = 0; i < threadCount; ++i)
+ producers[i].start();
+ for (int i = 0; i < threadCount; ++i)
+ producers[i].wait();
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"