From e106e218d83926f937e44d72792f8ed2645ed94c Mon Sep 17 00:00:00 2001
From: Tobias Hunger <qt-info@nokia.com>
Date: Thu, 19 Nov 2009 16:55:27 +0100
Subject: [PATCH] Do not mark env vars as modified if not needed.

 * Ignore steData calls that do not actually change any data
   in the EnvironmentEditorModel. This prevents all variables
   touched from getting marked up as changed.

Reviewed-By: con
---
 .../projectexplorer/environmenteditmodel.cpp  | 20 ++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/plugins/projectexplorer/environmenteditmodel.cpp b/src/plugins/projectexplorer/environmenteditmodel.cpp
index 422c8328c26..b34a7d64b22 100644
--- a/src/plugins/projectexplorer/environmenteditmodel.cpp
+++ b/src/plugins/projectexplorer/environmenteditmodel.cpp
@@ -234,15 +234,21 @@ int EnvironmentModel::findInResultInsertPosition(const QString &name) const
 bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value, int role)
 {
     if (role == Qt::EditRole && index.isValid()) {
+        // ignore changes to already set values:
+        if (data(index, role) == value)
+            return true;
+
         if (index.column() == 0) {
             //fail if a variable with the same name already exists
 #ifdef Q_OS_WIN
-            if (findInChanges(value.toString().toUpper()) != -1)
-                return false;
+            const QString &newName = value.toString().toUpper();
 #else
-            if (findInChanges(value.toString()) != -1)
-                return false;
+            const QString &newName = value.toString();
 #endif
+
+            if (findInChanges(newName) != -1)
+                return false;
+
             EnvironmentItem old("", "");
             if (m_mergedEnvironments) {
                 int pos = findInChanges(indexToVariable(index));
@@ -256,11 +262,7 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
             } else {
                 old = m_items.at(index.row());
             }
-#ifdef Q_OS_WIN
-            const QString &newName = value.toString().toUpper();
-#else
-            const QString &newName = value.toString();
-#endif
+
             if (changes(old.name))
                 removeVariable(old.name);
             old.name = newName;
-- 
GitLab