diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-08-13 18:36:04 +0300 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-08-19 19:17:17 +0300 |
commit | 7101dcab7a18ef0c9f9567901fd101814418a1f5 (patch) | |
tree | b0fa3195a2d56a7b0b91d7f02dc6c34270673718 /tests/auto/tools/qmake | |
parent | 192e1ed649c9cd961d73c97d0c76d0cb829bd47d (diff) |
tst_qmake: compile with QT_NO_FOREACH
systemEnvironment(): the loop was iterating over a temporary; hold the
temporary in a local const auto variable and use ranged-for.
runCommand(): the container is a const&, the loop doesn't change the
container and the containers the method is called on aren't changed
during iteration.
Task-number: QTBUG-115839
Change-Id: I6687e5ff64ff8c2fa26e34abf4044b98718e65d4
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests/auto/tools/qmake')
-rw-r--r-- | tests/auto/tools/qmake/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/tools/qmake/testcompiler.cpp | 7 |
2 files changed, 3 insertions, 6 deletions
diff --git a/tests/auto/tools/qmake/CMakeLists.txt b/tests/auto/tools/qmake/CMakeLists.txt index 6d046e66e3..8fe0566baa 100644 --- a/tests/auto/tools/qmake/CMakeLists.txt +++ b/tests/auto/tools/qmake/CMakeLists.txt @@ -17,8 +17,6 @@ qt_internal_add_test(tst_qmake SOURCES testcompiler.cpp testcompiler.h tst_qmake.cpp - NO_PCH_SOURCES - testcompiler.cpp # undef QT_NO_FOREACH TESTDATA ${test_data} ) diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp index e5a99ee224..4700b17a70 100644 --- a/tests/auto/tools/qmake/testcompiler.cpp +++ b/tests/auto/tools/qmake/testcompiler.cpp @@ -1,8 +1,6 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses - #include "testcompiler.h" #include <QProcess> @@ -106,7 +104,8 @@ static inline QStringList systemEnvironment() #ifdef Q_OS_WIN static QStringList result; if (result.isEmpty()) { - foreach (const QString &variable, QProcess::systemEnvironment()) { + const auto env = QProcess::systemEnvironment(); + for (const QString &variable : env) { if (variable.startsWith(QStringLiteral("MAKEFLAGS="), Qt::CaseInsensitive)) { qWarning("Removing environment setting '%s'", qPrintable(variable)); } else { @@ -125,7 +124,7 @@ bool TestCompiler::runCommand(const QString &cmd, const QStringList &args, bool QString dbg = cmd; if (dbg.contains(' ')) dbg.prepend('"').append('"'); - foreach (QString arg, args) { + for (QString arg : args) { if (arg.contains(' ')) arg.prepend('"').append('"'); dbg.append(' ').append(arg); |