summaryrefslogtreecommitdiffstats
path: root/src
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 16:08:29 (GMT)
commit0af0682ebbb70635f40dbed64d4cc678ade6bed2 (patch)
treefd53aac5f1837fa30e351bbfd4a3f34286cdc8de /src
parentf7feeee1733b6cb8bfcc157fff1e444068dc290c (diff)
downloadQt-0af0682ebbb70635f40dbed64d4cc678ade6bed2.zip
Qt-0af0682ebbb70635f40dbed64d4cc678ade6bed2.tar.gz
Qt-0af0682ebbb70635f40dbed64d4cc678ade6bed2.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>
Diffstat (limited to 'src')
-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 18c3c9f..1e6dcee 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);
+ }
}
}