diff options
author | João Abecasis <joao@abecasis.name> | 2009-07-16 15:54:22 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-07-17 17:06:10 (GMT) |
commit | c9579d44c6ce70066f90224c18ac964865290583 (patch) | |
tree | 9b58eccdd3b3d6ac3f0181ec267bcfdffb303f84 /src/corelib | |
parent | 62d95b8ef57f097422862cd2fa13f5debfbc8aae (diff) | |
download | Qt-c9579d44c6ce70066f90224c18ac964865290583.zip Qt-c9579d44c6ce70066f90224c18ac964865290583.tar.gz Qt-c9579d44c6ce70066f90224c18ac964865290583.tar.bz2 |
Refactoring QDirIteratorPrivate::pushSubDirectory
pushSubDirectory was operating on nextFileInfo when it should really be
using the path received as argument.
This fixes an issue introduced when currentFilePath variable was
removed, that was exposed in the auto-tests; fixes a regression
introduced in 4.5.0 -- test case a couple of commits back.
This also allows refactoring calling code and avoid repetition.
Task-number: 258230
Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qdiriterator.cpp | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index d372ed3..e48a1b9 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -106,7 +106,7 @@ public: QDir::Filters filters, QDirIterator::IteratorFlags flags); ~QDirIteratorPrivate(); - void pushSubDirectory(const QString &path, const QStringList &nameFilters, + void pushSubDirectory(const QFileInfo &fileInfo, const QStringList &nameFilters, QDir::Filters filters); void advance(); bool shouldFollowDirectory(const QFileInfo &); @@ -142,8 +142,7 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList this->nameFilters = nameFilters; nextFileInfo.setFile(path); - pushSubDirectory(nextFileInfo.isSymLink() ? nextFileInfo.canonicalFilePath() : path, - nameFilters, filters); + pushSubDirectory(nextFileInfo, nameFilters, filters); } /*! @@ -157,11 +156,18 @@ QDirIteratorPrivate::~QDirIteratorPrivate() /*! \internal */ -void QDirIteratorPrivate::pushSubDirectory(const QString &path, const QStringList &nameFilters, +void QDirIteratorPrivate::pushSubDirectory(const QFileInfo &fileInfo, const QStringList &nameFilters, QDir::Filters filters) { + QString path = fileInfo.filePath(); + +#ifdef Q_OS_WIN + if (fileInfo.isSymLink()) + path = fileInfo.canonicalFilePath(); +#endif + if (iteratorFlags & QDirIterator::FollowSymlinks) - visitedLinks << nextFileInfo.canonicalFilePath(); + visitedLinks << fileInfo.canonicalFilePath(); if (engine || (engine = QAbstractFileEngine::create(this->path))) { engine->setFileName(path); @@ -183,16 +189,9 @@ void QDirIteratorPrivate::advance() // Advance to the next entry if (followNextDir) { // Start by navigating into the current directory. - followNextDir = false; - QAbstractFileEngineIterator *it = fileEngineIterators.top(); - - QString subDir = it->currentFilePath(); -#ifdef Q_OS_WIN - if (nextFileInfo.isSymLink()) - subDir = nextFileInfo.canonicalFilePath(); -#endif - pushSubDirectory(subDir, it->nameFilters(), it->filters()); + pushSubDirectory(it->currentFileInfo(), it->nameFilters(), it->filters()); + followNextDir = false; } while (!fileEngineIterators.isEmpty()) { @@ -210,18 +209,8 @@ void QDirIteratorPrivate::advance() //We found a matching entry. return; - } else if (iteratorFlags & QDirIterator::Subdirectories) { - QFileInfo fileInfo = it->currentFileInfo(); - - if (!shouldFollowDirectory(fileInfo)) - continue; - QString subDir = it->currentFilePath(); -#ifdef Q_OS_WIN - if (fileInfo.isSymLink()) - subDir = fileInfo.canonicalFilePath(); -#endif - pushSubDirectory(subDir, it->nameFilters(), it->filters()); - + } else if (shouldFollowDirectory(it->currentFileInfo())) { + pushSubDirectory(it->currentFileInfo(), it->nameFilters(), it->filters()); foundDirectory = true; break; } |