forked from qt-creator/qt-creator
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 <tobias.hunger@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "qmlproject.h"
|
||||
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -39,28 +40,35 @@ namespace QmlProjectManager {
|
||||
|
||||
QList<int> QmlProjectEnvironmentAspect::possibleBaseEnvironments() const
|
||||
{
|
||||
return QList<int>() << static_cast<int>(KitEnvironmentBase)
|
||||
<< static_cast<int>(SystemEnvironmentBase);
|
||||
QList<int> 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<int>(SystemEnvironmentBase))
|
||||
switch (base) {
|
||||
case SystemEnvironmentBase:
|
||||
return tr("System Environment");
|
||||
if (base == static_cast<int>(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<int>(KitEnvironmentBase))
|
||||
runConfiguration()->target()->kit()->addToEnvironment(env);
|
||||
Utils::Environment env = baseEnvironmentBase() == SystemEnvironmentBase
|
||||
? Utils::Environment::systemEnvironment()
|
||||
: Utils::Environment();
|
||||
|
||||
QmlProject *project = qobject_cast<QmlProject *>(runConfiguration()->target()->project());
|
||||
if (project)
|
||||
if (QmlProject *project = qobject_cast<QmlProject *>(runConfiguration()->target()->project()))
|
||||
env.modify(project->environment());
|
||||
|
||||
return env;
|
||||
|
@@ -43,7 +43,7 @@ public:
|
||||
private:
|
||||
enum BaseEnvironmentBase {
|
||||
SystemEnvironmentBase = 0,
|
||||
KitEnvironmentBase
|
||||
CleanEnvironmentBase,
|
||||
};
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user