[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Wed Dec 22 00:38:58 CET 2004


CVS commit by staikos: 

- don't destroy what the user has already input when a dialog update happens

- fix a deadlock regression similar to the previous changefile deadlock, but
  in the data manager on delete


  M +27 -6     kstchangefiledialog_i.cpp   1.30
  M +4 -3      kstdatamanager_i.cpp   1.90


--- kdeextragear-2/kst/kst/kstchangefiledialog_i.cpp  #1.29:1.30
@@ -61,19 +61,36 @@ void KstChangeFileDialogI::selectAll() {
 
 void KstChangeFileDialogI::updateChangeFileDialog() {
-  ChangeFileCurveList->clear();
-
   KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
+  QStringList tags;
 
-  //
   // insert vectors into ChangeFileCurveList
-  //
   for (int i = 0; i < (int)rvl.count(); i++) {
     rvl[i]->readLock();
-    ChangeFileCurveList->insertItem(rvl[i]->tagName(), -1);
+    tags += rvl[i]->tagName();
     rvl[i]->readUnlock();
   }
 
+  QListBoxItem *bi = ChangeFileCurveList->firstItem();
+  while (bi) {
+    if (!tags.contains(bi->text())) {
+      QListBoxItem *del = bi;
+      bi = bi->next();
+      delete del;
+    } else {
+      bi = bi->next();
+    }
+  }
+
+  for (QStringList::ConstIterator i = tags.begin(); i != tags.end(); ++i) {
+    if (!ChangeFileCurveList->findItem(*i)) {
+      ChangeFileCurveList->insertItem(*i, -1);
+    }
+  }
+
+  if (!isShown()) {
   _dataFile->setURL(KST::vectorDefaults.dataSource());
+  }
 
+  QString currentFile = _files->currentText();
   _files->clear();
   KstReadLocker ml(&KST::dataSourceList.lock());
@@ -82,4 +99,8 @@ void KstChangeFileDialogI::updateChangeF
   }
 
+  if (_files->contains(currentFile)) {
+    _files->setCurrentText(currentFile);
+  }
+
   _allFromFile->setEnabled(_files->count() > 0);
   _files->setEnabled(_files->count() > 0);

--- kdeextragear-2/kst/kst/kstdatamanager_i.cpp  #1.89:1.90
@@ -505,10 +505,10 @@ void KstDataManagerI::delete_I() {
 
   if (koi->removable()) {
-    KstWriteLocker ml(&KST::vectorList.lock());
-
     if (qi->rtti() == RTTI_OBJ_OBJECT) {
       doc->removeDataObject(koi->tagName());
     } else if (qi->rtti() == RTTI_OBJ_DATA_VECTOR) {
+      KST::vectorList.lock().writeLock();
       KST::vectorList.removeTag(koi->tagName());
+      KST::vectorList.lock().writeUnlock();
       doUpdates();
     }
@@ -526,6 +526,7 @@ void KstDataManagerI::delete_I() {
           x->deleteDependents();
           x = 0L;
-          KstWriteLocker ml(&KST::vectorList.lock());
+          KST::vectorList.lock().writeLock();
           KST::vectorList.removeTag(koi->tagName());
+          KST::vectorList.lock().writeUnlock();
           doUpdates();
         } else {




More information about the Kst mailing list