RunConfiguration: Add a more explicit way to transfer creation info

... at RunConfig Creation time. This eases the id mangling case.

Use it in the PythonProject.

Change-Id: I9a7e2c90997ed5ab737cd4fa68895217bdbe1dfe
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2018-03-06 16:48:51 +01:00
parent d47237084d
commit 813bd806d3
3 changed files with 14 additions and 11 deletions

View File

@@ -147,6 +147,7 @@ public:
QVariantMap toMap() const override;
bool fromMap(const QVariantMap &map) override;
Runnable runnable() const override;
void doAdditionalSetup(const RunConfigurationCreationInfo &info) override;
bool supportsDebugger() const { return true; }
QString mainScript() const { return m_mainScript; }
@@ -171,12 +172,6 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target)
addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
addExtraAspect(new ArgumentsAspect(this, "PythonEditor.RunConfiguration.Arguments"));
addExtraAspect(new TerminalAspect(this, "PythonEditor.RunConfiguration.UseTerminal"));
Environment sysEnv = Environment::systemEnvironment();
const QString exec = sysEnv.searchInPath("python").toString();
m_interpreter = exec.isEmpty() ? "python" : exec;
setDefaultDisplayName(defaultDisplayName());
}
QVariantMap PythonRunConfiguration::toMap() const
@@ -193,14 +188,18 @@ bool PythonRunConfiguration::fromMap(const QVariantMap &map)
return false;
m_mainScript = map.value(MainScriptKey).toString();
m_interpreter = map.value(InterpreterKey).toString();
// FIXME: The following three lines can be removed once there is no id mangling anymore.
if (m_mainScript.isEmpty()) {
m_mainScript = ProjectExplorer::idFromMap(map).suffixAfter(id());
setDefaultDisplayName(defaultDisplayName());
}
return true;
}
void PythonRunConfiguration::doAdditionalSetup(const RunConfigurationCreationInfo &info)
{
Environment sysEnv = Environment::systemEnvironment();
const QString exec = sysEnv.searchInPath("python").toString();
m_interpreter = exec.isEmpty() ? "python" : exec;
m_mainScript = info.extra;
setDefaultDisplayName(defaultDisplayName());
}
QString PythonRunConfiguration::defaultDisplayName() const
{
return tr("Run %1").arg(m_mainScript);