summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpainter
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2010-10-26 13:46:11 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2010-10-27 10:14:05 (GMT)
commita87dbf0d08d58b829ca2fa036d589ad4fd48949f (patch)
tree2bfb93c21d1ffa1a0c083d1a7b104e88a4de6956 /tests/auto/qpainter
parente5ef6f580e1b601898a2fea095ed5be9823bab25 (diff)
downloadQt-a87dbf0d08d58b829ca2fa036d589ad4fd48949f.zip
Qt-a87dbf0d08d58b829ca2fa036d589ad4fd48949f.tar.gz
Qt-a87dbf0d08d58b829ca2fa036d589ad4fd48949f.tar.bz2
Fixed race condition in raster paint engine.
We need to protect the gradient cache accesses with a mutex. Task-number: QTBUG-14614 Reviewed-by: Bradley T. Hughes
Diffstat (limited to 'tests/auto/qpainter')
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index beb83a1..4146c5e 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -251,6 +251,8 @@ private slots:
void QTBUG5939_attachPainterPrivate();
+ void QTBUG14614_gradientCacheRaceCondition();
+
private:
void fillData();
void setPenColor(QPainter& p);
@@ -4458,6 +4460,36 @@ void tst_QPainter::QTBUG5939_attachPainterPrivate()
QCOMPARE(widget->deviceTransform, proxy->deviceTransform);
}
+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"