summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qimagereader.cpp
diff options
context:
space:
mode:
authoraavit <eirik.aavitsland@digia.com>2013-02-19 18:11:16 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-20 12:59:55 +0100
commite28c03cb829c229209090d7939a9aba1af1fdea9 (patch)
treec562120544fd1841d499f9e3ebfdd65f2852212d /src/gui/image/qimagereader.cpp
parentf6c5452d97c5bc53fd29c32e7f9bee0f5e411283 (diff)
Fix reentrancy problem in image reading
There were race conditions when accessing the plugin factory and the image reader plugins from different threads; ref QTBUG-29281. Added a mutex lock to avoid. Change-Id: Ic1a3b6cbaf5603f1bcf7025b58247a9a3f6d08a9 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/gui/image/qimagereader.cpp')
-rw-r--r--src/gui/image/qimagereader.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index 5eaf7bb8f2..684778694e 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -133,6 +133,7 @@
// factory loader
#include <qcoreapplication.h>
#include <private/qfactoryloader_p.h>
+#include <QMutexLocker>
// image handlers
#include <private/qbmphandler_p.h>
@@ -232,6 +233,9 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
QByteArray suffix;
#ifndef QT_NO_IMAGEFORMATPLUGIN
+ static QMutex mutex;
+ QMutexLocker locker(&mutex);
+
typedef QMultiMap<int, QString> PluginKeyMap;
// check if we have plugins that support the image format