diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2021-07-11 19:28:35 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2021-07-28 15:16:42 +0200 |
commit | 25fff849e8f34af6d41ff36f2891bb4099b89360 (patch) | |
tree | d34bb46cd97d25bd2abeee68c9060a1a9b40ff22 /qmake | |
parent | 8ccd5d5af295ae36440157fe1d00a176fdf1c6bf (diff) | |
download | qtbase-25fff849e8f34af6d41ff36f2891bb4099b89360.tar.gz |
QDirIterator: add nextFileInfo()
Before this change, next() was the only way to advance the iterator,
whether the caller was ultimately interested in just the filePath()
(good) or not (bad luck, had to call .fileInfo()).
Add a new function, nextFileInfo(), with returns fileInfo() instead.
Incidentally, the returned object has already been constructed as part
of advance()ing the iterator, so the new function is faster than
next() even if the result is ignored, because we're not calculating a
QString result the caller may not be interested in.
Use the new function around the code.
Fix a couple of cases of next(); fileInfo().filePath() (just use
next()'s return value) as a drive-by.
[ChangeLog][QtCore][QDirIterator] Added nextFileInfo(), which is like
next(), but returns fileInfo() instead of filePath().
Change-Id: I601220575961169b44139fc55b9eae6c3197afb4
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'qmake')
-rw-r--r-- | qmake/generators/win32/msvc_nmake.cpp | 3 | ||||
-rw-r--r-- | qmake/main.cpp | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index cf58ead2e9..50666215c6 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -338,8 +338,7 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t) for (const QString &sourceDir : qAsConst(fixifiedSourceDirs)) { QDirIterator dit(sourceDir, sourceFilesFilter, QDir::Files | QDir::NoDotAndDotDot); while (dit.hasNext()) { - dit.next(); - const QFileInfo fi = dit.fileInfo(); + const QFileInfo fi = dit.nextFileInfo(); QString &duplicate = fileNames[fi.completeBaseName()]; if (duplicate.isNull()) { duplicate = fi.filePath(); diff --git a/qmake/main.cpp b/qmake/main.cpp index d435ecaed8..e99b33bd21 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -341,8 +341,7 @@ static int installFileOrDirectory(const QString &source, const QString &target, QDirIterator it(source, QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden); while (it.hasNext()) { - it.next(); - const QFileInfo &entry = it.fileInfo(); + const QFileInfo entry = it.nextFileInfo(); const QString &entryTarget = target + QDir::separator() + entry.fileName(); const int recursionResult = installFileOrDirectory(entry.filePath(), entryTarget, true); |