diff options
author | João Abecasis <joao@trolltech.com> | 2010-02-02 19:34:23 (GMT) |
---|---|---|
committer | João Abecasis <joao@trolltech.com> | 2010-02-03 14:16:21 (GMT) |
commit | 14054a47230d41063a10ce8fbf7dc65c916163d7 (patch) | |
tree | 50cd404468e90d072bfbad3c6e6a88259318ed6f /src/corelib/io | |
parent | 63f66fb0008f93638de782b03f53e9777a941ab7 (diff) | |
download | Qt-14054a47230d41063a10ce8fbf7dc65c916163d7.zip Qt-14054a47230d41063a10ce8fbf7dc65c916163d7.tar.gz Qt-14054a47230d41063a10ce8fbf7dc65c916163d7.tar.bz2 |
QDir fix issues with (shared) cached lists
With 2964718224c0ed356511335742368d4fc421c6bd, QDir started really using
the cached file lists. However, these were not being properly updated on
setNameFilters, setFilter and setSorting.
QDir::refresh, on the other hand, would invalidate the lists without
first detaching, thus breaking the copy-on-write promise.
Summarizing, shared data must be detached and cached lists invalidated,
so they get regenerated.
Reviewed-by: Olivier Goffart
Reviewed-by: Ritt Konstantin
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qdir.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 250e5e5..f5d803e 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -960,7 +960,7 @@ void QDir::setNameFilters(const QStringList &nameFilters) { Q_D(QDir); - d->detach(); + d->reset(); d->data->nameFilters = nameFilters; } @@ -1146,7 +1146,7 @@ void QDir::setFilter(Filters filters) { Q_D(QDir); - d->detach(); + d->reset(); d->data->filters = filters; } @@ -1204,7 +1204,7 @@ void QDir::setSorting(SortFlags sort) { Q_D(QDir); - d->detach(); + d->reset(); d->data->sort = sort; } @@ -2155,7 +2155,7 @@ void QDir::refresh() const { Q_D(const QDir); - d->data->clear(); + const_cast<QDirPrivate *>(d)->reset(); } /*! @@ -2244,6 +2244,8 @@ bool QDir::matchAllDirs() const void QDir::setMatchAllDirs(bool on) { Q_D(QDir); + + d->reset(); d->matchAllDirs = on; } |