summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTijl Coosemans <tijl@coosemans.org>2010-11-26 09:11:12 (GMT)
committerJoão Abecasis <joao.abecasis@nokia.com>2010-11-26 09:11:12 (GMT)
commit58020d06ed5b3e7e429454e4dc267b4713a70d08 (patch)
treeffefab92463a12139a3a9ef219d276331206d591
parentb3b1ddf6f8dca6fa12817c74298ed9c80e173c7c (diff)
downloadQt-58020d06ed5b3e7e429454e4dc267b4713a70d08.zip
Qt-58020d06ed5b3e7e429454e4dc267b4713a70d08.tar.gz
Qt-58020d06ed5b3e7e429454e4dc267b4713a70d08.tar.bz2
QPollingFileSystemWatcherEngine: Fix double report of directory change.
The polling engine first retrieves a QFileInfo for a given path, then tests whether it's different from before and if so, stores the new file info and emits a signal. In case path is a directory the test also checks if the list of directory entries has changed. This creates a window between retrieving the file info and the test in which a file can be added/removed from the directory or the directory itself can be removed. In that case the test returns true, because the list of entries has changed, but outdated file info is stored which means that on the next timeout the same change will be reported a second time. Therefore, refresh the file info after the test for changes. Merge-request: 2425 Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index 3a7d795..4d0d495 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -228,8 +228,14 @@ void QPollingFileSystemWatcherEngine::timeout()
dit.remove();
emit directoryChanged(path, true);
} else if (x.value() != fi) {
- x.value() = fi;
- emit directoryChanged(path, false);
+ fi.refresh();
+ if (!fi.exists()) {
+ dit.remove();
+ emit directoryChanged(path, true);
+ } else {
+ x.value() = fi;
+ emit directoryChanged(path, false);
+ }
}
}