Commit 78b0c59a authored by Tobias Hunger's avatar Tobias Hunger

Make RunSettingsWidget more robust

Handle a situation that can never happen but caused a crash.
parent 6061c405
...@@ -191,8 +191,7 @@ RunSettingsWidget::RunSettingsWidget(Target *target) ...@@ -191,8 +191,7 @@ RunSettingsWidget::RunSettingsWidget(Target *target)
m_ui->removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1); m_ui->removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);
m_ui->renameRunButton->setEnabled(m_target->activeRunConfiguration()); m_ui->renameRunButton->setEnabled(m_target->activeRunConfiguration());
m_runConfigurationWidget = m_target->activeRunConfiguration()->createConfigurationWidget(); setConfigurationWidget(m_target->activeRunConfiguration());
m_runLayout->addWidget(m_runConfigurationWidget);
connect(m_addRunMenu, SIGNAL(aboutToShow()), connect(m_addRunMenu, SIGNAL(aboutToShow()),
this, SLOT(aboutToShowAddMenu())); this, SLOT(aboutToShowAddMenu()));
...@@ -280,10 +279,6 @@ void RunSettingsWidget::activeRunConfigurationChanged() ...@@ -280,10 +279,6 @@ void RunSettingsWidget::activeRunConfigurationChanged()
m_ignoreChange = true; m_ignoreChange = true;
m_ui->runConfigurationCombo->setCurrentIndex(actRc.row()); m_ui->runConfigurationCombo->setCurrentIndex(actRc.row());
m_ignoreChange = false; m_ignoreChange = false;
delete m_runConfigurationWidget;
m_runConfigurationWidget = m_target->activeRunConfiguration()->createConfigurationWidget();
m_runLayout->addWidget(m_runConfigurationWidget);
} }
void RunSettingsWidget::renameRunConfiguration() void RunSettingsWidget::renameRunConfiguration()
...@@ -308,22 +303,17 @@ void RunSettingsWidget::currentRunConfigurationChanged(int index) ...@@ -308,22 +303,17 @@ void RunSettingsWidget::currentRunConfigurationChanged(int index)
{ {
if (m_ignoreChange) if (m_ignoreChange)
return; return;
if (index == -1) {
delete m_runConfigurationWidget; RunConfiguration *selectedRunConfiguration = 0;
m_runConfigurationWidget = 0; if (index >= 0)
return; selectedRunConfiguration = m_runConfigurationsModel->runConfigurationAt(index);
}
RunConfiguration *selectedRunConfiguration =
m_runConfigurationsModel->runConfigurationAt(index);
m_ignoreChange = true; m_ignoreChange = true;
m_target->setActiveRunConfiguration(selectedRunConfiguration); m_target->setActiveRunConfiguration(selectedRunConfiguration);
m_ignoreChange = false; m_ignoreChange = false;
// Update the run configuration configuration widget // Update the run configuration configuration widget
delete m_runConfigurationWidget; setConfigurationWidget(selectedRunConfiguration);
m_runConfigurationWidget = selectedRunConfiguration->createConfigurationWidget();
m_runLayout->addWidget(m_runConfigurationWidget);
} }
void RunSettingsWidget::currentDeployConfigurationChanged(int index) void RunSettingsWidget::currentDeployConfigurationChanged(int index)
...@@ -424,6 +414,16 @@ void RunSettingsWidget::updateDeployConfiguration(DeployConfiguration *dc) ...@@ -424,6 +414,16 @@ void RunSettingsWidget::updateDeployConfiguration(DeployConfiguration *dc)
m_deployLayout->addWidget(m_deploySteps); m_deployLayout->addWidget(m_deploySteps);
} }
void RunSettingsWidget::setConfigurationWidget(RunConfiguration *rc)
{
delete m_runConfigurationWidget;
m_runConfigurationWidget = 0;
if (!rc)
return;
m_runConfigurationWidget = m_target->activeRunConfiguration()->createConfigurationWidget();
m_runLayout->addWidget(m_runConfigurationWidget);
}
QString RunSettingsWidget::uniqueDCName(const QString &name) QString RunSettingsWidget::uniqueDCName(const QString &name)
{ {
QString result = name.trimmed(); QString result = name.trimmed();
......
...@@ -50,6 +50,7 @@ namespace ProjectExplorer { ...@@ -50,6 +50,7 @@ namespace ProjectExplorer {
class DeployConfiguration; class DeployConfiguration;
class DeployConfigurationWidget; class DeployConfigurationWidget;
class DeployConfigurationModel; class DeployConfigurationModel;
class RunConfiguration;
class RunConfigurationModel; class RunConfigurationModel;
namespace Internal { namespace Internal {
...@@ -112,6 +113,7 @@ private: ...@@ -112,6 +113,7 @@ private:
QString uniqueDCName(const QString &name); QString uniqueDCName(const QString &name);
QString uniqueRCName(const QString &name); QString uniqueRCName(const QString &name);
void updateDeployConfiguration(DeployConfiguration *); void updateDeployConfiguration(DeployConfiguration *);
void setConfigurationWidget(RunConfiguration *rc);
Target *m_target; Target *m_target;
RunConfigurationModel *m_runConfigurationsModel; RunConfigurationModel *m_runConfigurationsModel;
......
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