From b409a81da5d0d14b3ac96497f60c1b599bac60a7 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 11 Jan 2012 12:47:07 +0100 Subject: Ensure proper locking in QFileInfoGatherer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mutex is used to protect the QFileSystemWatcher instance created by QFileInfoGatherer, except when calling getFileInfos(). Add a locker before using QFileSystemWatcher in this function. Note: it appears that QFileInfoGatherer is misusing QFileSystemWatcher by calling it from multiple threads. QFileSystemWatcher is an event driven class, and as such, not thread-safe. So far, no problems have been reported related to this, so I've left the code as-is. Change-Id: Ib1429d9399e37120acf8e8d3b989b83c4ce24203 Reviewed-by: João Abecasis --- src/widgets/dialogs/qfileinfogatherer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp index 1e08dbd1a5..bce8b3ecc1 100644 --- a/src/widgets/dialogs/qfileinfogatherer.cpp +++ b/src/widgets/dialogs/qfileinfogatherer.cpp @@ -280,10 +280,11 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil { #ifndef QT_NO_FILESYSTEMWATCHER if (files.isEmpty() - && !watcher->directories().contains(path) && !path.isEmpty() && !path.startsWith(QLatin1String("//")) /*don't watch UNC path*/) { - watcher->addPath(path); + QMutexLocker locker(&mutex); + if (!watcher->directories().contains(path)) + watcher->addPath(path); } #endif -- cgit v1.2.3