diff options
author | dt <qtc-committer@nokia.com> | 2009-07-15 14:23:38 +0200 |
---|---|---|
committer | dt <qtc-committer@nokia.com> | 2009-07-15 14:23:38 +0200 |
commit | 0c58fe61b18317d071ac27857bd8cf4d52ec6703 (patch) | |
tree | c36ecf2ec77e69050695c0e65ecea39e2d81a9cc /src/corelib/io/qfilesystemwatcher_win_p.h | |
parent | a6782030bc6077b3b1ffe380dfd303cfb7662795 (diff) |
Support more than 63 handles in QWindowsFileSystemWatcher
We spawn/stop additional threads as needed to watch any number of
files/directories. The old logic of using just one handle per watched
directory (regardless of how many files we watch in it.) is preserved.
In the worst case a thread is started per 63 files to watch.
This enabled Qt Creator to watch all .pro and .pri files even while
having qt's projects.pro and qtcreator.pro open.
Task-number: 185259, 253014
Reviewed-by: denis
Diffstat (limited to 'src/corelib/io/qfilesystemwatcher_win_p.h')
-rw-r--r-- | src/corelib/io/qfilesystemwatcher_win_p.h | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/src/corelib/io/qfilesystemwatcher_win_p.h b/src/corelib/io/qfilesystemwatcher_win_p.h index 5d42cac652..405d255230 100644 --- a/src/corelib/io/qfilesystemwatcher_win_p.h +++ b/src/corelib/io/qfilesystemwatcher_win_p.h @@ -68,27 +68,24 @@ QT_BEGIN_NAMESPACE +class QWindowsFileSystemWatcherEngineThread; + +// Even though QWindowsFileSystemWatcherEngine is derived of QThread +// via QFileSystemWatcher, it does not start a thread. +// Instead QWindowsFileSystemWatcher creates QWindowsFileSystemWatcherEngineThreads +// to do the actually watching. class QWindowsFileSystemWatcherEngine : public QFileSystemWatcherEngine { Q_OBJECT - public: QWindowsFileSystemWatcherEngine(); ~QWindowsFileSystemWatcherEngine(); - void run(); - QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories); QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories); void stop(); -private: - void wakeup(); - - QMutex mutex; - QVector<HANDLE> handles; - int msg; class Handle { @@ -97,13 +94,12 @@ private: uint flags; Handle() - : handle(INVALID_HANDLE_VALUE), flags(0u) + : handle(INVALID_HANDLE_VALUE), flags(0u) { } Handle(const Handle &other) - : handle(other.handle), flags(other.flags) + : handle(other.handle), flags(other.flags) { } }; - QHash<QString, Handle> handleForDir; class PathInfo { public: @@ -118,7 +114,7 @@ private: QDateTime lastModified; PathInfo &operator=(const QFileInfo &fileInfo) - { + { ownerId = fileInfo.ownerId(); groupId = fileInfo.groupId(); permissions = fileInfo.permissions(); @@ -134,8 +130,35 @@ private: || lastModified != fileInfo.lastModified()); } }; - QHash<HANDLE, QHash<QString, PathInfo> > pathInfoForHandle; +private: + QList<QWindowsFileSystemWatcherEngineThread *> threads; + +}; + +class QWindowsFileSystemWatcherEngineThread : public QThread +{ + Q_OBJECT + +public: + QWindowsFileSystemWatcherEngineThread(); + ~QWindowsFileSystemWatcherEngineThread(); + void run(); + void stop(); + void wakeup(); + + QMutex mutex; + QVector<HANDLE> handles; + int msg; + + QHash<QString, QWindowsFileSystemWatcherEngine::Handle> handleForDir; + + QHash<HANDLE, QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> > pathInfoForHandle; + +Q_SIGNALS: + void fileChanged(const QString &path, bool removed); + void directoryChanged(const QString &path, bool removed); }; + #endif // QT_NO_FILESYSTEMWATCHER QT_END_NAMESPACE |