summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qfileinfogatherer.cpp
diff options
context:
space:
mode:
authorBernd Weimer <bweimer@blackberry.com>2014-06-06 13:29:03 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-06-30 22:02:02 +0200
commit5f7ea1a41aa9e299130f335b0023b9026de841c5 (patch)
treec3d2858b8118c6b5e52b7c5df5555f923965b7ff /src/widgets/dialogs/qfileinfogatherer.cpp
parent60b6b28c213a420ee40e254ff1823876098e0a04 (diff)
Fix QFileInfoGatherer threading issue
QFileInfoGatherer has a QFileSystemWatcher member that lives in the same thread as the QFileInfoGatherer object. If only the poller engine is available for the file system watcher, the engine will only be created when addPaths() is called. However the latter was called from anohter thread (the QFileInfoGatherer thread). Hence the QPollingFileSystemWatcherEngine had its parent in a different thread and worse, this thread didn't have an event loop needed for the QTimer used in the poller engine. This fixes tst_qfilesystemmodel on platforms that only support the polling file system watcher engine. Task-Number: QTBUG-29366 Change-Id: I83b58b4237e3438a27e5cdde4b1e4126e4740a94 Reviewed-by: Fabian Bumberger <fbumberger@rim.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/widgets/dialogs/qfileinfogatherer.cpp')
-rw-r--r--src/widgets/dialogs/qfileinfogatherer.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp
index b08cc798e5..41b0b30eeb 100644
--- a/src/widgets/dialogs/qfileinfogatherer.cpp
+++ b/src/widgets/dialogs/qfileinfogatherer.cpp
@@ -146,6 +146,15 @@ void QFileInfoGatherer::fetchExtendedInformation(const QString &path, const QStr
this->path.push(path);
this->files.push(files);
condition.wakeAll();
+
+#ifndef QT_NO_FILESYSTEMWATCHER
+ if (files.isEmpty()
+ && !path.isEmpty()
+ && !path.startsWith(QLatin1String("//")) /*don't watch UNC path*/) {
+ if (!watcher->directories().contains(path))
+ watcher->addPath(path);
+ }
+#endif
}
/*!
@@ -269,16 +278,6 @@ static QString translateDriveName(const QFileInfo &drive)
*/
void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &files)
{
-#ifndef QT_NO_FILESYSTEMWATCHER
- if (files.isEmpty()
- && !path.isEmpty()
- && !path.startsWith(QLatin1String("//")) /*don't watch UNC path*/) {
- QMutexLocker locker(&mutex);
- if (!watcher->directories().contains(path))
- watcher->addPath(path);
- }
-#endif
-
// List drives
if (path.isEmpty()) {
#ifdef QT_BUILD_INTERNAL