From 4070bb1daafafabebb3c893a472a22fab413e4de Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 5 Mar 2010 13:24:29 +0100 Subject: 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 --- src/corelib/io/qfilesystemwatcher_fsevents.cpp | 2 ++ 1 file changed, 2 insertions(+) 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) -- cgit v0.12