[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Thu Dec 22 06:19:31 CET 2005


SVN commit 490489 by staikos:

get rid of deadlock and move variables where they belong


 M  +15 -15    kstchangefiledialog_i.cpp  


--- trunk/extragear/graphics/kst/kst/kstchangefiledialog_i.cpp #490488:490489
@@ -146,20 +146,16 @@
   }
   KST::dataSourceList.lock().writeUnlock();
 
-  file->writeLock();
-
   KstApp *app = KstApp::inst();
   KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
   KstRMatrixList rml = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
   int selected = 0;
   int handled = 0;
-  int count;
-  int i;
 
-  count = (int)ChangeFileCurveList->count();
-  for (i = 0; i < count; i++) {
+  int count = (int)ChangeFileCurveList->count();
+  for (int i = 0; i < count; i++) {
     if (ChangeFileCurveList->isSelected(i)) {
-      selected++;
+      ++selected;
     }
   }
 
@@ -170,18 +166,21 @@
   QMap<KstMatrixPtr, KstMatrixPtr> duplicatedMatrices;
   
   // go through the vectors
-  for (i = 0; i < (int)rvl.count(); i++) {
+  for (int i = 0; i < (int)rvl.count(); i++) {
     if (ChangeFileCurveList->isSelected(i)) {
       KstRVectorPtr vector = rvl[i];
       vector->writeLock();
-      if (!file->isValidField(vector->field())) {
+      file->readLock();
+      bool valid = file->isValidField(vector->field());
+      file->readUnlock();
+      if (!valid) {
         if (invalid > 0) {
           // FIXME: invalid list construction for i18n
           invalidSources = i18n("%1, %2").arg(invalidSources).arg(vector->field());
         } else {
           invalidSources = vector->field();
         }
-        invalid++;
+        ++invalid;
       } else {
         if (_duplicateSelected->isChecked()) {
           
@@ -205,18 +204,21 @@
   }
   
   // go through the matrices
-  for (i = (int)rvl.count(); i < (int)ChangeFileCurveList->count(); i++) {
+  for (int i = (int)rvl.count(); i < (int)ChangeFileCurveList->count(); i++) {
     if (ChangeFileCurveList->isSelected(i)) {
       KstRMatrixPtr matrix = rml[i-rvl.count()];
       matrix->writeLock();
-      if (!file->isValidMatrix(matrix->field())) {
+      file->readLock();
+      bool valid = file->isValidMatrix(matrix->field());
+      file->readUnlock();
+      if (!valid) {
         if (invalid > 0) {
           // FIXME: invalid list construction for i18n
           invalidSources = i18n("%1, %2").arg(invalidSources).arg(matrix->field());
         } else {
           invalidSources = matrix->field();
         }
-        invalid++;
+        ++invalid;
       } else {
         if (_duplicateSelected->isChecked()) {
           
@@ -240,8 +242,6 @@
   }
 
   app->slotUpdateProgress(0, 0, QString::null);
-
-  file->writeUnlock();
   file = 0L;
   
   // now add any curves and images to plots if they were duplicated


More information about the Kst mailing list