summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-10-30 13:57:41 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-10-30 13:57:41 (GMT)
commit349b6c734aa7af85f3709312325c3b2e9abdad2b (patch)
tree2617b30b5cfeeedf3b63a7c3251779766fc1276f
parente8c01ab0e5fb6134617a69d88ed0cbce24a33da5 (diff)
parent5cd971bb508e1288573d32a996183f3e9359c90e (diff)
downloadQt-349b6c734aa7af85f3709312325c3b2e9abdad2b.zip
Qt-349b6c734aa7af85f3709312325c3b2e9abdad2b.tar.gz
Qt-349b6c734aa7af85f3709312325c3b2e9abdad2b.tar.bz2
Merge branch 'qt-4.7-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration into 4.7-integration
* 'qt-4.7-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration: Fix Windows compilation. Fixed race condition in raster paint engine.
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp3
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp33
2 files changed, 36 insertions, 0 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 8f9d8ba..3717ed9 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include <QtCore/qglobal.h>
+#include <QtCore/qmutex.h>
#define QT_FT_BEGIN_HEADER
#define QT_FT_END_HEADER
@@ -4946,6 +4947,7 @@ public:
for (int i = 0; i < stops.size() && i <= 2; i++)
hash_val += stops[i].second.rgba();
+ QMutexLocker lock(&mutex);
QGradientColorTableHash::const_iterator it = cache.constFind(hash_val);
if (it == cache.constEnd())
@@ -4979,6 +4981,7 @@ protected:
}
QGradientColorTableHash cache;
+ QMutex mutex;
};
void QGradientCache::generateGradientColorTable(const QGradient& gradient, uint *colorTable, int size, int opacity) const
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"