Commit c6c90a15 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Fix possible crash in environmenteditmodel

 * Do not trigger resets of the model when not necessary
 * Actually handle resets of the model when necessary

Tasknumber: QTCREATORBUG-1172
Reviewed-by: dt
parent 9e937b59
......@@ -70,6 +70,8 @@ void EnvironmentModel::updateResultEnvironment()
void EnvironmentModel::setBaseEnvironment(const ProjectExplorer::Environment &env)
{
if (m_baseEnvironment == env)
return;
beginResetModel();
m_baseEnvironment = env;
updateResultEnvironment();
......@@ -340,6 +342,9 @@ QList<EnvironmentItem> EnvironmentModel::userChanges() const
void EnvironmentModel::setUserChanges(QList<EnvironmentItem> list)
{
// We assume nobody is reordering the items here.
if (list == m_items)
return;
beginResetModel();
m_items = list;
updateResultEnvironment();
......@@ -356,6 +361,8 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails
m_model = new EnvironmentModel();
connect(m_model, SIGNAL(userChangesChanged()),
this, SIGNAL(userChangesChanged()));
connect(m_model, SIGNAL(modelReset()),
this, SLOT(invalidateCurrentIndex()));
connect(m_model, SIGNAL(renamedVariable(QString)),
this, SLOT(renamedVariable(QString)));
......@@ -538,3 +545,8 @@ void EnvironmentWidget::environmentCurrentIndexChanged(const QModelIndex &curren
m_unsetButton->setEnabled(false);
}
}
void EnvironmentWidget::invalidateCurrentIndex()
{
environmentCurrentIndexChanged(QModelIndex());
}
......@@ -122,6 +122,7 @@ private slots:
void removeEnvironmentButtonClicked();
void unsetEnvironmentButtonClicked();
void environmentCurrentIndexChanged(const QModelIndex &current);
void invalidateCurrentIndex();
void updateSummaryText();
void renamedVariable(const QString &name);
......
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