forked from qt-creator/qt-creator
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:
@@ -559,6 +559,8 @@ RunConfiguration *IRunConfigurationFactory::create(Target *parent,
|
|||||||
QVariantMap data2 = rc->toMap();
|
QVariantMap data2 = rc->toMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc->doAdditionalSetup(info);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class BuildConfiguration;
|
|||||||
class IRunConfigurationAspect;
|
class IRunConfigurationAspect;
|
||||||
class IRunConfigurationFactory;
|
class IRunConfigurationFactory;
|
||||||
class RunConfiguration;
|
class RunConfiguration;
|
||||||
|
class RunConfigurationCreationInfo;
|
||||||
class RunConfigWidget;
|
class RunConfigWidget;
|
||||||
class RunControl;
|
class RunControl;
|
||||||
class Target;
|
class Target;
|
||||||
@@ -268,6 +269,7 @@ protected:
|
|||||||
BuildConfiguration *activeBuildConfiguration() const;
|
BuildConfiguration *activeBuildConfiguration() const;
|
||||||
|
|
||||||
virtual void updateEnabledState();
|
virtual void updateEnabledState();
|
||||||
|
virtual void doAdditionalSetup(const RunConfigurationCreationInfo &) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void addAspectFactory(const AspectFactory &aspectFactory);
|
static void addAspectFactory(const AspectFactory &aspectFactory);
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ public:
|
|||||||
QVariantMap toMap() const override;
|
QVariantMap toMap() const override;
|
||||||
bool fromMap(const QVariantMap &map) override;
|
bool fromMap(const QVariantMap &map) override;
|
||||||
Runnable runnable() const override;
|
Runnable runnable() const override;
|
||||||
|
void doAdditionalSetup(const RunConfigurationCreationInfo &info) override;
|
||||||
|
|
||||||
bool supportsDebugger() const { return true; }
|
bool supportsDebugger() const { return true; }
|
||||||
QString mainScript() const { return m_mainScript; }
|
QString mainScript() const { return m_mainScript; }
|
||||||
@@ -171,12 +172,6 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target)
|
|||||||
addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
|
addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
|
||||||
addExtraAspect(new ArgumentsAspect(this, "PythonEditor.RunConfiguration.Arguments"));
|
addExtraAspect(new ArgumentsAspect(this, "PythonEditor.RunConfiguration.Arguments"));
|
||||||
addExtraAspect(new TerminalAspect(this, "PythonEditor.RunConfiguration.UseTerminal"));
|
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
|
QVariantMap PythonRunConfiguration::toMap() const
|
||||||
@@ -193,14 +188,18 @@ bool PythonRunConfiguration::fromMap(const QVariantMap &map)
|
|||||||
return false;
|
return false;
|
||||||
m_mainScript = map.value(MainScriptKey).toString();
|
m_mainScript = map.value(MainScriptKey).toString();
|
||||||
m_interpreter = map.value(InterpreterKey).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;
|
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
|
QString PythonRunConfiguration::defaultDisplayName() const
|
||||||
{
|
{
|
||||||
return tr("Run %1").arg(m_mainScript);
|
return tr("Run %1").arg(m_mainScript);
|
||||||
|
|||||||
Reference in New Issue
Block a user