summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystemwatcher_fsevents_p.h
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-10-11 07:40:32 +0200
committerLiang Qi <liang.qi@qt.io>2016-10-11 07:40:32 +0200
commit905329200f2f3f9372bf07a001371c30c0663684 (patch)
treee6f072ea693c377ae306b3960f4bde36ee20bc17 /src/corelib/io/qfilesystemwatcher_fsevents_p.h
parent91cde062968f97041bca8d2a30d13aa03b606c3d (diff)
parent1a78ef09b93b0a7337075555dc91032f39fab2a9 (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: src/gui/image/qpixmap.cpp src/widgets/kernel/qformlayout.cpp Change-Id: I8a8391a202adf7f18464a22ddf0a6c4974eab692
Diffstat (limited to 'src/corelib/io/qfilesystemwatcher_fsevents_p.h')
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents_p.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents_p.h b/src/corelib/io/qfilesystemwatcher_fsevents_p.h
index dc4e5bf38b..1b0b8ae15c 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents_p.h
+++ b/src/corelib/io/qfilesystemwatcher_fsevents_p.h
@@ -87,7 +87,7 @@ Q_SIGNALS:
private slots:
void doEmitFileChanged(const QString &path, bool removed);
void doEmitDirectoryChanged(const QString &path, bool removed);
- void restartStream();
+ bool restartStream();
private:
struct Info {
@@ -118,6 +118,19 @@ private:
typedef QHash<QString, DirInfo> DirsByName;
typedef QHash<QString, qint64> PathRefCounts;
+ struct WatchingState {
+ // These fields go hand-in-hand. FSEvents watches paths, and there is no use in watching
+ // the same path multiple times. So, the "refcount" on a path is the number of watched
+ // files that have the same path, plus the number of directories that have the same path.
+ //
+ // If the stream fails to start after adding files/directories, the watcher will try to
+ // keep watching files/directories that it was already watching. It does that by restoring
+ // the previous WatchingState and restarting the stream.
+ FilesByPath watchedFiles;
+ DirsByName watchedDirectories;
+ PathRefCounts watchedPaths;
+ };
+
QFseventsFileSystemWatcherEngine(QObject *parent);
bool startStream();
void stopStream(bool isStopped = false);
@@ -131,10 +144,8 @@ private:
QMutex lock;
dispatch_queue_t queue;
FSEventStreamRef stream;
- FilesByPath watchedFiles;
- DirsByName watchedDirectories;
- PathRefCounts watchedPaths;
FSEventStreamEventId lastReceivedEvent;
+ WatchingState watchingState;
};
QT_END_NAMESPACE