diff --git a/src/plugins/projectexplorer/environmenteditmodel.cpp b/src/plugins/projectexplorer/environmenteditmodel.cpp
index cfe2796ca93858699b15d19b5a719f7a5ac8488e..8a17cc23ee159c0b53acff5449a66448afd6d9a7 100644
--- a/src/plugins/projectexplorer/environmenteditmodel.cpp
+++ b/src/plugins/projectexplorer/environmenteditmodel.cpp
@@ -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());
+}
diff --git a/src/plugins/projectexplorer/environmenteditmodel.h b/src/plugins/projectexplorer/environmenteditmodel.h
index da1f81cac6864a012bb559690f7435149f8ed797..60eea7bc5183c24ffd1f2f38327b5c9d4d7345e0 100644
--- a/src/plugins/projectexplorer/environmenteditmodel.h
+++ b/src/plugins/projectexplorer/environmenteditmodel.h
@@ -122,6 +122,7 @@ private slots:
     void removeEnvironmentButtonClicked();
     void unsetEnvironmentButtonClicked();
     void environmentCurrentIndexChanged(const QModelIndex &current);
+    void invalidateCurrentIndex();
     void updateSummaryText();
     void renamedVariable(const QString &name);