From 5179dbbe688e0dc01708432eebe444003c24c439 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 21 Feb 2018 17:01:45 +0100 Subject: [PATCH] QmlProject: Clean up environment selection On desktop you get "system environment" as default now and "clean environment" as option. "kit environment" doesn't make any sense as that is meant for build configurations. On remote Devices you only get "clean environment" because we cannot query the generic remote device for its default environment. However, as the environment was rather random before and it worked, a clean environment will probably not break it. Change-Id: Iab0ed804a21cf77db9e3413926ff710c91561db0 Task-number: QTCREATORBUG-19887 Reviewed-by: Tobias Hunger Reviewed-by: Tim Jenssen --- .../qmlprojectenvironmentaspect.cpp | 32 ++++++++++++------- .../qmlprojectenvironmentaspect.h | 2 +- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/plugins/qmlprojectmanager/qmlprojectenvironmentaspect.cpp b/src/plugins/qmlprojectmanager/qmlprojectenvironmentaspect.cpp index 5cc6fe9988c..a4721ada4e4 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectenvironmentaspect.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectenvironmentaspect.cpp @@ -27,6 +27,7 @@ #include "qmlproject.h" +#include #include #include #include @@ -39,28 +40,35 @@ namespace QmlProjectManager { QList QmlProjectEnvironmentAspect::possibleBaseEnvironments() const { - return QList() << static_cast(KitEnvironmentBase) - << static_cast(SystemEnvironmentBase); + QList ret; + if (ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(runConfiguration()->target()->kit()) + == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { + ret << SystemEnvironmentBase; + } + ret << CleanEnvironmentBase; + return ret; } QString QmlProjectEnvironmentAspect::baseEnvironmentDisplayName(int base) const { - if (base == static_cast(SystemEnvironmentBase)) + switch (base) { + case SystemEnvironmentBase: return tr("System Environment"); - if (base == static_cast(KitEnvironmentBase)) - return tr("Kit Environment"); - return QString(); + case CleanEnvironmentBase: + return tr("Clean Environment"); + default: + QTC_CHECK(false); + return QString(); + } } Utils::Environment QmlProjectEnvironmentAspect::baseEnvironment() const { - int base = baseEnvironmentBase(); - Utils::Environment env = Utils::Environment::systemEnvironment(); - if (base == static_cast(KitEnvironmentBase)) - runConfiguration()->target()->kit()->addToEnvironment(env); + Utils::Environment env = baseEnvironmentBase() == SystemEnvironmentBase + ? Utils::Environment::systemEnvironment() + : Utils::Environment(); - QmlProject *project = qobject_cast(runConfiguration()->target()->project()); - if (project) + if (QmlProject *project = qobject_cast(runConfiguration()->target()->project())) env.modify(project->environment()); return env; diff --git a/src/plugins/qmlprojectmanager/qmlprojectenvironmentaspect.h b/src/plugins/qmlprojectmanager/qmlprojectenvironmentaspect.h index 14c460085f6..efa32fdfdb4 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectenvironmentaspect.h +++ b/src/plugins/qmlprojectmanager/qmlprojectenvironmentaspect.h @@ -43,7 +43,7 @@ public: private: enum BaseEnvironmentBase { SystemEnvironmentBase = 0, - KitEnvironmentBase + CleanEnvironmentBase, }; };