Commit 9f86cfaf authored by dt's avatar dt

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
m_buildTarget(target),
m_workingDirectory(workingDirectory),
m_title(title),
m_baseEnvironmentBase(CMakeRunConfiguration::BuildEnvironmentBase)
m_baseEnvironmentBase(CMakeRunConfiguration::BuildEnvironmentBase),
m_enabled(true)
{
ctor();
}
......@@ -94,7 +95,8 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeTarget *parent, CMakeRunConfig
m_title(source->m_title),
m_arguments(source->m_arguments),
m_userEnvironmentChanges(source->m_userEnvironmentChanges),
m_baseEnvironmentBase(source->m_baseEnvironmentBase)
m_baseEnvironmentBase(source->m_baseEnvironmentBase),
m_enabled(source->m_enabled)
{
ctor();
}
......@@ -293,9 +295,21 @@ ProjectExplorer::ToolChain::ToolChainType CMakeRunConfiguration::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)
: QWidget(parent), m_ignoreChange(false), m_cmakeRunConfiguration(cmakeRunConfiguration)
{
......
......@@ -81,6 +81,11 @@ public:
QVariantMap toMap() const;
void setEnabled(bool b);
bool isEnabled(ProjectExplorer::BuildConfiguration *bc) const;
using LocalApplicationRunConfiguration::isEnabled;
signals:
void baseEnvironmentChanged();
void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &diff);
......@@ -115,6 +120,7 @@ private:
QString m_arguments;
QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
BaseEnvironmentBase m_baseEnvironmentBase;
bool m_enabled;
};
class CMakeRunConfigurationWidget : public QWidget
......
......@@ -120,6 +120,7 @@ void CMakeTarget::updateRunConfigurations()
foreach (CMakeRunConfiguration *rc, list) {
rc->setExecutable(ct.executable);
rc->setWorkingDirectory(ct.workingDirectory);
rc->setEnabled(true);
}
existingRunConfigurations.remove(ct.title);
} else {
......@@ -131,7 +132,10 @@ void CMakeTarget::updateRunConfigurations()
existingRunConfigurations.constBegin();
for( ; it != existingRunConfigurations.constEnd(); ++it) {
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()) {
// Oh no, no run configuration,
......
Markdown is supported
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