summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-06-10 18:18:03 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2011-06-13 14:07:21 (GMT)
commit59f186869c67ab51fccf3aac3153629a1da285b7 (patch)
tree10d8102e6dd186628f27eda66b6cc9579db2b0d4
parent63729b15d4e08401d383f4d38eee6a290e8ba894 (diff)
downloadQt-59f186869c67ab51fccf3aac3153629a1da285b7.zip
Qt-59f186869c67ab51fccf3aac3153629a1da285b7.tar.gz
Qt-59f186869c67ab51fccf3aac3153629a1da285b7.tar.bz2
QFileInfoGatherer: call QFileSystemWatcher addPaths from proper thread
QFSW isn't thread safe. With removal of the thread inside QFSW, the addPaths and removePaths must be called from the thread the QFSW was created in. Reviewed-by: joao
-rw-r--r--src/gui/dialogs/qfileinfogatherer.cpp13
-rw-r--r--src/gui/dialogs/qfileinfogatherer_p.h1
2 files changed, 10 insertions, 4 deletions
diff --git a/src/gui/dialogs/qfileinfogatherer.cpp b/src/gui/dialogs/qfileinfogatherer.cpp
index 315b931..06c9f39 100644
--- a/src/gui/dialogs/qfileinfogatherer.cpp
+++ b/src/gui/dialogs/qfileinfogatherer.cpp
@@ -170,7 +170,6 @@ void QFileInfoGatherer::updateFile(const QString &filePath)
void QFileInfoGatherer::clear()
{
#ifndef QT_NO_FILESYSTEMWATCHER
- QMutexLocker locker(&mutex);
watcher->removePaths(watcher->files());
watcher->removePaths(watcher->directories());
#endif
@@ -184,11 +183,18 @@ void QFileInfoGatherer::clear()
void QFileInfoGatherer::removePath(const QString &path)
{
#ifndef QT_NO_FILESYSTEMWATCHER
- QMutexLocker locker(&mutex);
watcher->removePath(path);
#endif
}
+void QFileInfoGatherer::addPath(const QString &path)
+{
+#ifndef QT_NO_FILESYSTEMWATCHER
+ if (!watcher->directories().contains(path))
+ watcher->addPath(path);
+#endif
+}
+
/*
List all files in \a directoryPath
@@ -280,10 +286,9 @@ 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);
+ QMetaObject::invokeMethod(this, "addPath", Q_ARG(QString, path));
}
#endif
diff --git a/src/gui/dialogs/qfileinfogatherer_p.h b/src/gui/dialogs/qfileinfogatherer_p.h
index 98217c1..bff4f69 100644
--- a/src/gui/dialogs/qfileinfogatherer_p.h
+++ b/src/gui/dialogs/qfileinfogatherer_p.h
@@ -162,6 +162,7 @@ public:
void clear();
void removePath(const QString &path);
+ Q_INVOKABLE void addPath(const QString& path);
QExtendedInformation getInfo(const QFileInfo &info) const;
public Q_SLOTS: