diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-03-05 12:24:29 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-03-05 12:31:57 (GMT) |
commit | 4070bb1daafafabebb3c893a472a22fab413e4de (patch) | |
tree | 7d314d1bce054022db22b4131a1b8252e1b965e8 | |
parent | 4575f3f0024e6b095df856a0dd7b37118c935116 (diff) | |
download | Qt-4070bb1daafafabebb3c893a472a22fab413e4de.zip Qt-4070bb1daafafabebb3c893a472a22fab413e4de.tar.gz Qt-4070bb1daafafabebb3c893a472a22fab413e4de.tar.bz2 |
Prevent a freeze of QFileSystemWatcher on Mac.
On Mac when the FSEvents backend is used and a file is added or removed from a
file system watcher, we need to wait until the thread is finished, otherwise it
is possible that the thread already exited from the run() function but hasn't
fully terminated, meaning when we restart the thread by calling start() it
won't start because QThread thinks it's already running.
A better fix might be to avoid stopping and starting threads - to just stop the
FSEvents loop and notify the thread that a file set has changed.
Task-number: QTBUG-8524
Reviewed-by: Morten
-rw-r--r-- | src/corelib/io/qfilesystemwatcher_fsevents.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.cpp b/src/corelib/io/qfilesystemwatcher_fsevents.cpp index efbc290..d3276bd 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.cpp +++ b/src/corelib/io/qfilesystemwatcher_fsevents.cpp @@ -171,6 +171,7 @@ QStringList QFSEventsFileSystemWatcherEngine::addPaths(const QStringList &paths, { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 stop(); + wait(); QMutexLocker locker(&mutex); QStringList failedToAdd; // if we have a running FSStreamEvent, we have to kill it, we'll re-add the stream soon. @@ -268,6 +269,7 @@ QStringList QFSEventsFileSystemWatcherEngine::removePaths(const QStringList &pat { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 stop(); + wait(); QMutexLocker locker(&mutex); // short circuit for smarties that call remove before add and we have nothing. if (pathsToWatch == 0) |