From d10ce822ca7cf5bee8b199e99cc2ea67337d9ad4 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 5 Nov 2019 11:30:22 +0100 Subject: [PATCH] Run configurations: Let env widget reflect changes to lib search path This broke in some refactoring. Fixes: QTCREATORBUG-23165 Change-Id: Icb98234d83c6cb45a68562b88ee11fc9453bf6b3 Reviewed-by: hjk --- src/plugins/projectexplorer/environmentaspect.cpp | 8 +++++++- src/plugins/projectexplorer/environmentaspect.h | 5 ++++- src/plugins/projectexplorer/environmentaspectwidget.cpp | 8 ++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/plugins/projectexplorer/environmentaspect.cpp b/src/plugins/projectexplorer/environmentaspect.cpp index 68eff436209..94dc0e12eb5 100644 --- a/src/plugins/projectexplorer/environmentaspect.cpp +++ b/src/plugins/projectexplorer/environmentaspect.cpp @@ -72,12 +72,18 @@ void EnvironmentAspect::setUserEnvironmentChanges(const Utils::EnvironmentItems } Utils::Environment EnvironmentAspect::environment() const +{ + Environment env = modifiedBaseEnvironment(); + env.modify(m_userChanges); + return env; +} + +Environment EnvironmentAspect::modifiedBaseEnvironment() const { QTC_ASSERT(m_base >= 0 && m_base < m_baseEnvironments.size(), return Environment()); Environment env = m_baseEnvironments.at(m_base).unmodifiedBaseEnvironment(); for (const EnvironmentModifier &modifier : m_modifiers) modifier(env); - env.modify(m_userChanges); return env; } diff --git a/src/plugins/projectexplorer/environmentaspect.h b/src/plugins/projectexplorer/environmentaspect.h index ef5ed2907e8..271a809bdc8 100644 --- a/src/plugins/projectexplorer/environmentaspect.h +++ b/src/plugins/projectexplorer/environmentaspect.h @@ -46,6 +46,9 @@ public: // The environment including the user's modifications. Utils::Environment environment() const; + // Environment including modifiers, but without explicit user changes. + Utils::Environment modifiedBaseEnvironment() const; + int baseEnvironmentBase() const; void setBaseEnvironmentBase(int base); @@ -57,7 +60,7 @@ public: void addPreferredBaseEnvironment(const QString &displayName, const std::function &getter); - // The environment the user chose as base for his modifications. + // The pure base environment. Utils::Environment currentUnmodifiedBaseEnvironment() const; QString currentDisplayName() const; diff --git a/src/plugins/projectexplorer/environmentaspectwidget.cpp b/src/plugins/projectexplorer/environmentaspectwidget.cpp index d846c1b303a..280cc5ac9da 100644 --- a/src/plugins/projectexplorer/environmentaspectwidget.cpp +++ b/src/plugins/projectexplorer/environmentaspectwidget.cpp @@ -75,7 +75,7 @@ EnvironmentAspectWidget::EnvironmentAspectWidget(EnvironmentAspect *aspect, QWid const EnvironmentWidget::Type widgetType = aspect->isLocal() ? EnvironmentWidget::TypeLocal : EnvironmentWidget::TypeRemote; m_environmentWidget = new EnvironmentWidget(this, widgetType, baseEnvironmentWidget); - m_environmentWidget->setBaseEnvironment(m_aspect->currentUnmodifiedBaseEnvironment()); + m_environmentWidget->setBaseEnvironment(m_aspect->modifiedBaseEnvironment()); m_environmentWidget->setBaseEnvironmentText(m_aspect->currentDisplayName()); m_environmentWidget->setUserChanges(m_aspect->userEnvironmentChanges()); m_environmentWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -106,7 +106,7 @@ void EnvironmentAspectWidget::baseEnvironmentSelected(int idx) { m_ignoreChange = true; m_aspect->setBaseEnvironmentBase(idx); - m_environmentWidget->setBaseEnvironment(m_aspect->currentUnmodifiedBaseEnvironment()); + m_environmentWidget->setBaseEnvironment(m_aspect->modifiedBaseEnvironment()); m_environmentWidget->setBaseEnvironmentText(m_aspect->currentDisplayName()); m_ignoreChange = false; } @@ -122,7 +122,7 @@ void EnvironmentAspectWidget::changeBaseEnvironment() m_baseEnvironmentComboBox->setCurrentIndex(i); } m_environmentWidget->setBaseEnvironmentText(m_aspect->currentDisplayName()); - m_environmentWidget->setBaseEnvironment(m_aspect->currentUnmodifiedBaseEnvironment()); + m_environmentWidget->setBaseEnvironment(m_aspect->modifiedBaseEnvironment()); } void EnvironmentAspectWidget::userChangesEdited() @@ -143,7 +143,7 @@ void EnvironmentAspectWidget::environmentChanged() { if (m_ignoreChange) return; - m_environmentWidget->setBaseEnvironment(m_aspect->currentUnmodifiedBaseEnvironment()); + m_environmentWidget->setBaseEnvironment(m_aspect->modifiedBaseEnvironment()); } } // namespace ProjectExplorer