Commit 9f86cfaf authored by dt's avatar dt
Browse files

Cmake: Don't delete run configurations on switching buildconfigurations

Just disable them, but preserve them. This is different from qmake, but
for qmake we do have different assumptions what a buildconfiguration is.

Task-Nr: QTCREATORBUG-1591
parent 17f8cfe2
...@@ -80,7 +80,8 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeTarget *parent, const QString ...@@ -80,7 +80,8 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeTarget *parent, const QString
m_buildTarget(target), m_buildTarget(target),
m_workingDirectory(workingDirectory), m_workingDirectory(workingDirectory),
m_title(title), m_title(title),
m_baseEnvironmentBase(CMakeRunConfiguration::BuildEnvironmentBase) m_baseEnvironmentBase(CMakeRunConfiguration::BuildEnvironmentBase),
m_enabled(true)
{ {
ctor(); ctor();
} }
...@@ -94,7 +95,8 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeTarget *parent, CMakeRunConfig ...@@ -94,7 +95,8 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeTarget *parent, CMakeRunConfig
m_title(source->m_title), m_title(source->m_title),
m_arguments(source->m_arguments), m_arguments(source->m_arguments),
m_userEnvironmentChanges(source->m_userEnvironmentChanges), m_userEnvironmentChanges(source->m_userEnvironmentChanges),
m_baseEnvironmentBase(source->m_baseEnvironmentBase) m_baseEnvironmentBase(source->m_baseEnvironmentBase),
m_enabled(source->m_enabled)
{ {
ctor(); ctor();
} }
...@@ -293,9 +295,21 @@ ProjectExplorer::ToolChain::ToolChainType CMakeRunConfiguration::toolChainType() ...@@ -293,9 +295,21 @@ ProjectExplorer::ToolChain::ToolChainType CMakeRunConfiguration::toolChainType()
return bc->toolChainType(); return bc->toolChainType();
} }
// Configuration widget void CMakeRunConfiguration::setEnabled(bool b)
{
if (m_enabled == b)
return;
m_enabled = b;
emit isEnabledChanged(isEnabled());
setDisplayName(m_title + (m_enabled ? "" : tr(" (disabled)")));
}
bool CMakeRunConfiguration::isEnabled(ProjectExplorer::BuildConfiguration *bc) const
{
return m_enabled && LocalApplicationRunConfiguration::isEnabled(bc);
}
// Configuration widget
CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent) CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent)
: QWidget(parent), m_ignoreChange(false), m_cmakeRunConfiguration(cmakeRunConfiguration) : QWidget(parent), m_ignoreChange(false), m_cmakeRunConfiguration(cmakeRunConfiguration)
{ {
......
...@@ -81,6 +81,11 @@ public: ...@@ -81,6 +81,11 @@ public:
QVariantMap toMap() const; QVariantMap toMap() const;
void setEnabled(bool b);
bool isEnabled(ProjectExplorer::BuildConfiguration *bc) const;
using LocalApplicationRunConfiguration::isEnabled;
signals: signals:
void baseEnvironmentChanged(); void baseEnvironmentChanged();
void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &diff); void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &diff);
...@@ -115,6 +120,7 @@ private: ...@@ -115,6 +120,7 @@ private:
QString m_arguments; QString m_arguments;
QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges; QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
BaseEnvironmentBase m_baseEnvironmentBase; BaseEnvironmentBase m_baseEnvironmentBase;
bool m_enabled;
}; };
class CMakeRunConfigurationWidget : public QWidget class CMakeRunConfigurationWidget : public QWidget
......
...@@ -120,6 +120,7 @@ void CMakeTarget::updateRunConfigurations() ...@@ -120,6 +120,7 @@ void CMakeTarget::updateRunConfigurations()
foreach (CMakeRunConfiguration *rc, list) { foreach (CMakeRunConfiguration *rc, list) {
rc->setExecutable(ct.executable); rc->setExecutable(ct.executable);
rc->setWorkingDirectory(ct.workingDirectory); rc->setWorkingDirectory(ct.workingDirectory);
rc->setEnabled(true);
} }
existingRunConfigurations.remove(ct.title); existingRunConfigurations.remove(ct.title);
} else { } else {
...@@ -131,7 +132,10 @@ void CMakeTarget::updateRunConfigurations() ...@@ -131,7 +132,10 @@ void CMakeTarget::updateRunConfigurations()
existingRunConfigurations.constBegin(); existingRunConfigurations.constBegin();
for( ; it != existingRunConfigurations.constEnd(); ++it) { for( ; it != existingRunConfigurations.constEnd(); ++it) {
CMakeRunConfiguration *rc = it.value(); CMakeRunConfiguration *rc = it.value();
removeRunConfiguration(rc); // The executables for those runconfigurations aren't build by the current buildconfiguration
// We just set a disable flag and show that in the display name
rc->setEnabled(false);
// removeRunConfiguration(rc);
} }
if (runConfigurations().isEmpty()) { if (runConfigurations().isEmpty()) {
// Oh no, no run configuration, // Oh no, no run configuration,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment