From 21de068c148402f185f5ef5028f5fe88c2620a59 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 2 Mar 2023 12:21:58 +0100 Subject: [PATCH] RemoteLinux: Avoid some explicit uses of environment iterators Task-number: QTCREATORBUG-28357 Change-Id: Ic8eb7592853749a7d511acc9a528059765c4ed75 Reviewed-by: Christian Kandeler --- src/plugins/remotelinux/linuxdevice.cpp | 5 +++-- src/plugins/remotelinux/makeinstallstep.cpp | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index 754a7f0281e..d38542fefde 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -613,8 +613,9 @@ QString LinuxProcessInterface::fullCommandLine(const CommandLine &commandLine) c cmd.addArgs(QString("echo ") + s_pidMarker + "$$" + s_pidMarker + " && ", CommandLine::Raw); const Environment &env = m_setup.m_environment; - for (auto it = env.constBegin(); it != env.constEnd(); ++it) - cmd.addArgs(env.key(it) + "='" + env.expandedValueForKey(env.key(it)) + '\'', CommandLine::Raw); + env.forEachEntry([&](const QString &key, const QString &, bool) { + cmd.addArgs(key + "='" + env.expandedValueForKey(key) + '\'', CommandLine::Raw); + }); if (m_setup.m_terminalMode == TerminalMode::Off) cmd.addArg("exec"); diff --git a/src/plugins/remotelinux/makeinstallstep.cpp b/src/plugins/remotelinux/makeinstallstep.cpp index ea7b6364586..a23dba21037 100644 --- a/src/plugins/remotelinux/makeinstallstep.cpp +++ b/src/plugins/remotelinux/makeinstallstep.cpp @@ -172,12 +172,10 @@ bool MakeInstallStep::init() const MakeInstallCommand cmd = buildSystem()->makeInstallCommand(rootDir); if (cmd.environment.hasChanges()) { Environment env = processParameters()->environment(); - for (auto it = cmd.environment.constBegin(); it != cmd.environment.constEnd(); ++it) { - if (cmd.environment.isEnabled(it)) { - const QString key = cmd.environment.key(it); + cmd.environment.forEachEntry([&](const QString &key, const QString &, bool enabled) { + if (enabled) env.set(key, cmd.environment.expandedValueForKey(key)); - } - } + }); processParameters()->setEnvironment(env); } m_noInstallTarget = false;