summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystemwatcher_fsevents_p.h
diff options
context:
space:
mode:
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