Fix various mis-uses of Environment::forEachEntry()

Most of them introduced with 08bacd3f19.

Fixes: QTCREATORBUG-29857
Change-Id: Ia897958865f00cb5f8f141659a652aee05aa1355
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2023-11-06 16:46:26 +01:00
parent 824fee183c
commit d62309bbb2
5 changed files with 24 additions and 13 deletions

View File

@@ -116,8 +116,10 @@ static Environment getEnvCombined(const std::optional<Environment> &optPresetEnv
Environment result = env;
if (optPresetEnv) {
optPresetEnv->forEachEntry([&result](const QString &key, const QString &value, bool) {
result.set(key, value);
optPresetEnv->forEachEntry([&result](const QString &key, const QString &value,
bool enabled) {
if (enabled)
result.set(key, value);
});
}
@@ -128,7 +130,9 @@ template<class PresetType>
void expand(const PresetType &preset, Environment &env, const FilePath &sourceDirectory)
{
const Environment presetEnv = getEnvCombined(preset.environment, env);
presetEnv.forEachEntry([&](const QString &key, const QString &value_, bool) {
presetEnv.forEachEntry([&](const QString &key, const QString &value_, bool enabled) {
if (!enabled)
return;
QString value = value_;
expandAllButEnv(preset, sourceDirectory, value);
value = expandMacroEnv("env", value, [presetEnv](const QString &macroName) {
@@ -163,7 +167,9 @@ template<class PresetType>
void expand(const PresetType &preset, EnvironmentItems &envItems, const FilePath &sourceDirectory)
{
const Environment presetEnv = preset.environment ? *preset.environment : Environment();
presetEnv.forEachEntry([&](const QString &key, const QString &value_, bool) {
presetEnv.forEachEntry([&](const QString &key, const QString &value_, bool enabled) {
if (!enabled)
return;
QString value = value_;
expandAllButEnv(preset, sourceDirectory, value);
value = expandMacroEnv("env", value, [presetEnv](const QString &macroName) {