summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs/qfilesystemmodel.cpp
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2010-03-29 23:58:07 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2010-03-30 00:02:49 (GMT)
commit30ada569454de1ec1d10bf7261d413ddd9b962a5 (patch)
tree33d06535ff250c30adc9bb91e1111e7915b937bc /src/gui/dialogs/qfilesystemmodel.cpp
parent780f0cf58d93babd4bbfb5d3d00156a96fc7dacb (diff)
downloadQt-30ada569454de1ec1d10bf7261d413ddd9b962a5.zip
Qt-30ada569454de1ec1d10bf7261d413ddd9b962a5.tar.gz
Qt-30ada569454de1ec1d10bf7261d413ddd9b962a5.tar.bz2
Fix QFileSystemModel to not install useless watchers on the filesystem
When someone call setRootPath we need to remove the previous watcher. This save memory and also it avoids Qt Creator to run out of filesystem watcher which then leads to a crash. If you call setRootPath on the previous path all changes that might happen in between will be propagated in the model. Task-number:QTBUG-8632 Reviewed-by:Friedemann Kleint
Diffstat (limited to 'src/gui/dialogs/qfilesystemmodel.cpp')
-rw-r--r--src/gui/dialogs/qfilesystemmodel.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp
index 6fd947c..3757ad7 100644
--- a/src/gui/dialogs/qfilesystemmodel.cpp
+++ b/src/gui/dialogs/qfilesystemmodel.cpp
@@ -1361,6 +1361,16 @@ QModelIndex QFileSystemModel::setRootPath(const QString &newPath)
if (!showDrives && !newPathDir.exists())
return d->index(rootPath());
+ //We remove the watcher on the previous path
+ if (!rootPath().isEmpty()) {
+ //This remove the watcher for the old rootPath
+ d->fileInfoGatherer.removePath(rootPath());
+ //This line "marks" the node as dirty, so the next fetchMore
+ //call on the path will ask the gatherer to install a watcher again
+ //But it doesn't re-fetch everything
+ d->node(rootPath())->populatedChildren = false;
+ }
+
// We have a new valid root path
d->rootDir = newPathDir;
QModelIndex newRootIndex;