From 0be8f763d54d8567e2bc8f1da8196773b6d9fd36 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 8 Aug 2023 07:56:32 +0200 Subject: [PATCH] tst_rcc: port away from Q_FOREACH Most of these are of trivial kind (loops over const locals). The one that isn't, in cleanupTestCase(), is, however, also simple: it's a loop over a local, too, but it would be too much churn to change the initialization to make the container const, and the loop body clearly doesn't modify the container, so just go with the std::as_const() pattern here. Task-number: QTBUG-115839 Change-Id: I188a78ea67a63be2d50a81fea431e5ea9f2783cb Reviewed-by: Ivan Solovev Reviewed-by: Qt CI Bot (cherry picked from commit 961717d372ad94b90e8d06152e92f1af54810a25) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/tools/rcc/tst_rcc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index 1ed3b5f2cd6..629bce923da 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -211,8 +211,8 @@ static QStringMap readExpectedFiles(const QString &fileName) { QStringMap expectedFiles; - QStringList lines = readLinesFromFile(fileName, Qt::SkipEmptyParts); - foreach (const QString &line, lines) { + const QStringList lines = readLinesFromFile(fileName, Qt::SkipEmptyParts); + for (const QString &line : lines) { QString resourceFileName = line.section(QLatin1Char(' '), 0, 0, QString::SectionSkipEmpty); QString actualFileName = line.section(QLatin1Char(' '), 1, 1, QString::SectionSkipEmpty); expectedFiles[resourceFileName] = actualFileName; @@ -276,8 +276,8 @@ void tst_rcc::binary_data() QString localeFileName = absoluteBaseName + QLatin1String(".locale"); QFile localeFile(localeFileName); if (localeFile.exists()) { - QStringList locales = readLinesFromFile(localeFileName, Qt::SkipEmptyParts); - foreach (const QString &locale, locales) { + const QStringList locales = readLinesFromFile(localeFileName, Qt::SkipEmptyParts); + for (const QString &locale : locales) { QString expectedFileName = QString::fromLatin1("%1.%2.%3").arg(absoluteBaseName, locale, QLatin1String("expected")); QStringMap expectedFiles = readExpectedFiles(expectedFileName); QTest::newRow(qPrintable(qrcFileInfo.baseName() + QLatin1Char('_') + locale)) << rccFileName @@ -473,7 +473,7 @@ void tst_rcc::cleanupTestCase() QFileInfoList entries = dataDir.entryInfoList(QStringList() << QLatin1String("*.rcc")); QDir dataDepDir(m_dataPath + QLatin1String("/depfile")); entries += dataDepDir.entryInfoList({QLatin1String("*.d"), QLatin1String("*.qrc.cpp")}); - foreach (const QFileInfo &entry, entries) + for (const QFileInfo &entry : std::as_const(entries)) QFile::remove(entry.absoluteFilePath()); }