Index: Qt/Components/pqSignalAdaptorSelectionTreeWidget.cxx
===================================================================
RCS file: /cvsroot/ParaView3/ParaView3/Qt/Components/pqSignalAdaptorSelectionTreeWidget.cxx,v
retrieving revision 1.8
diff -u -r1.8 pqSignalAdaptorSelectionTreeWidget.cxx
--- Qt/Components/pqSignalAdaptorSelectionTreeWidget.cxx	10 Nov 2008 15:43:43 -0000	1.8
+++ Qt/Components/pqSignalAdaptorSelectionTreeWidget.cxx	26 Mar 2010 03:49:10 -0000
@@ -97,9 +97,10 @@
   QObject::connect(this->Internal->TreeWidget->model(),
     SIGNAL(modelReset()),
     this, SIGNAL(valuesChanged()));
-  QObject::connect(this->Internal->TreeWidget->model(),
-    SIGNAL(rowsInserted(const QModelIndex&, int, int)),
-    this, SIGNAL(valuesChanged()));
+  // No signal emission when new items are appended
+  // QObject::connect(this->Internal->TreeWidget->model(),
+  //   SIGNAL(rowsInserted(const QModelIndex&, int, int)),
+  //   this, SIGNAL(valuesChanged()));
   QObject::connect(this->Internal->TreeWidget->model(),
     SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
     this, SIGNAL(valuesChanged()));
@@ -181,7 +182,7 @@
   QList<QList<QVariant> > oldValues = this->values();
 
   bool equal = true;
-  if(oldValues.size() == newDomain.size())
+  if(oldValues.size() <= newDomain.size())
     {
     for(int i=0; equal && i<oldValues.size(); i++)
       {
@@ -196,20 +197,28 @@
     equal = false;
     }
 
-  if(equal)
+  if(equal && oldValues.size() == newDomain.size())
     {
     return;
     }
- 
+
   // Domain changes should not change the property values. This is overriding
   // the value loaded from state files etc.
   // this->Internal->Property->ResetToDefault();
-  
+
   QList<QList<QVariant> > newValues =
     pqSMAdaptor::getSelectionProperty(this->Internal->Property);
 
-  // Now update the tree widget. We hide any elements no longer in the domain.
-  this->Internal->TreeWidget->clear();
+  if(equal)
+    {
+    // Erase items that are already in the widget
+    newValues.erase(newValues.begin(), newValues.begin() + oldValues.size());
+    }
+  else
+    {
+    // Now update the tree widget. We hide any elements no longer in the domain.
+    this->Internal->TreeWidget->clear();
+    }
 
   foreach (QList<QVariant> newValue, newValues)
     {
@@ -218,13 +227,16 @@
       {
       item = (*this->ItemCreatorFunctionPtr)(this->Internal->TreeWidget, 
         QStringList(newValue[0].toString()));
+      item->setCheckState(0, newValue[1].toInt() ? Qt::Checked : Qt::Unchecked);
       }
     if (!item)
       {
-      item  = new QTreeWidgetItem(this->Internal->TreeWidget,
-        QStringList(newValue[0].toString()));
+      item  = new QTreeWidgetItem(QStringList(newValue[0].toString()));
+      // Set check state before insertion in order to avoid
+      // dataChanged() to be triggered
+      item->setCheckState(0, newValue[1].toInt() ? Qt::Checked : Qt::Unchecked);
+      this->Internal->TreeWidget->addTopLevelItem(item);
       }
-    item->setCheckState(0, newValue[1].toInt() ? Qt::Checked : Qt::Unchecked);
     }
 }
 
