From 890a61fba008c49d93e0715e2883f350b9ecb1ab Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sun, 13 Aug 2023 18:18:10 +0300 Subject: [PATCH] tst_selftests: compile with QT_NO_FOREACH The loop was iterating over a temporary container, so it couldn't have changed it. Use a const auto variable to hold the container and port to ranged-for Task-number: QTBUG-115839 Change-Id: I66e7cbdb811666ca352cdf064b1228caa346d876 Reviewed-by: Volker Hilsheimer --- tests/auto/testlib/selftests/tst_selftests.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index e9bf64d3be..c95070a773 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -2,8 +2,6 @@ // Copyright (C) 2016 Intel Corporation. // 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 QT_REQUIRE_CONFIG(process); @@ -934,7 +932,8 @@ static QProcessEnvironment testEnvironment() if (environment.isEmpty()) { const QProcessEnvironment systemEnvironment = QProcessEnvironment::systemEnvironment(); const bool preserveLibPath = qEnvironmentVariableIsSet("QT_PRESERVE_TESTLIB_PATH"); - foreach (const QString &key, systemEnvironment.keys()) { + const auto envKeys = systemEnvironment.keys(); + for (const QString &key : envKeys) { const bool useVariable = key == "PATH" || key == "QT_QPA_PLATFORM" #if defined(Q_OS_QNX) || key == "GRAPHICS_ROOT" || key == "TZ"