From 5f7ea1a41aa9e299130f335b0023b9026de841c5 Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Fri, 6 Jun 2014 13:29:03 +0200 Subject: 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 Reviewed-by: Thiago Macieira --- src/widgets/dialogs/qfileinfogatherer.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/widgets/dialogs/qfileinfogatherer.cpp') 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 -- cgit v1.2.3