[Kst] extragear/graphics/kst/src

Eli Fidler eli at staikos.net
Thu Feb 8 00:29:36 CET 2007


SVN commit 631423 by fidler:

disable display tag updating where appropriate

better error checking


 M  +45 -0     libkstapp/kstdoc.cpp  
 M  +3 -1      libkstmath/kstbasicplugin.cpp  
 M  +12 -1     libkstmath/kstcplugin.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kstdoc.cpp #631422:631423
@@ -302,6 +302,25 @@
   app->slotUpdateProgress(count, handled, readingDocument);
 
   kapp->dcopClient()->setAcceptCalls(false);
+
+  // disable display tags for speed
+  {
+    KstWriteLocker ml(&KST::matrixList.lock());
+    KST::matrixList.setUpdateDisplayTags(false);
+  }
+  {
+    KstWriteLocker sl(&KST::scalarList.lock());
+    KST::scalarList.setUpdateDisplayTags(false);
+  }
+  {
+    KstWriteLocker sl(&KST::stringList.lock());
+    KST::stringList.setUpdateDisplayTags(false);
+  }
+  {
+    KstWriteLocker vl(&KST::vectorList.lock());
+    KST::vectorList.setUpdateDisplayTags(false);
+  }
+
   while (!n.isNull()) {
     QDomElement e = n.toElement(); // try to convert the node to an element.
     if (!e.isNull()) { // the node was really an element.
@@ -368,15 +387,20 @@
           KST::dataSourceList.append(file);
         }
       } else if (e.tagName() == "scalar") {
+        KstWriteLocker sl(&KST::scalarList.lock());
         new KstScalar(e);
       } else if (e.tagName() == "string") {
+        KstWriteLocker sl(&KST::stringList.lock());
         new KstString(e);
       } else if (e.tagName() == "vector") {
+        KstWriteLocker vl(&KST::vectorList.lock());
         vector = new KstRVector(e, o_file, o_n, o_f, o_s, o_ave);
         // Vectors are automatically added to the global list.
       } else if (e.tagName() == "svector") {
+        KstWriteLocker vl(&KST::vectorList.lock());
         KstSVectorPtr svector = new KstSVector(e);
       } else if (e.tagName() == "avector") {
+        KstWriteLocker vl(&KST::vectorList.lock());
         KstAVectorPtr avector = new KstAVector(e);
       } else if (e.tagName() == "plugin") {
         const QString name = e.attribute("name");
@@ -430,10 +454,13 @@
         Kst2DPlotPtr plot = new Kst2DPlot(e);
         app->plotHolderWhileOpeningDocument()->insert(plot->tagName(), plot);
       } else if (e.tagName() == "amatrix") {
+        KstWriteLocker ml(&KST::matrixList.lock());
         KstAMatrixPtr p = new KstAMatrix(e);
       } else if (e.tagName() == "smatrix") {
+        KstWriteLocker ml(&KST::matrixList.lock());
         KstSMatrixPtr p = new KstSMatrix(e);
       } else if (e.tagName() == "rmatrix") {
+        KstWriteLocker ml(&KST::matrixList.lock());
         KstRMatrixPtr p = new KstRMatrix(e);
       } else if (e.tagName() == "image") {
         KstDataObjectPtr p = new KstImage(e);
@@ -469,6 +496,24 @@
     kapp->eventLoop()->processEvents(QEventLoop::ExcludeSocketNotifiers, 10);
   }
 
+  // reenable display tags
+  {
+    KstWriteLocker ml(&KST::matrixList.lock());
+    KST::matrixList.setUpdateDisplayTags(true);
+  }
+  {
+    KstWriteLocker sl(&KST::scalarList.lock());
+    KST::scalarList.setUpdateDisplayTags(true);
+  }
+  {
+    KstWriteLocker sl(&KST::stringList.lock());
+    KST::stringList.setUpdateDisplayTags(true);
+  }
+  {
+    KstWriteLocker vl(&KST::vectorList.lock());
+    KST::vectorList.setUpdateDisplayTags(true);
+  }
+
   if (warnOldKstFile) {
     QApplication::restoreOverrideCursor();
     KMessageBox::sorry(KstApp::inst(), i18n("You tried to load an old Kst file.  Curves created by equations or PSDs will not be loaded."));
--- trunk/extragear/graphics/kst/src/libkstmath/kstbasicplugin.cpp #631422:631423
@@ -289,12 +289,13 @@
       int i = 0;
       int length = vectorParam->length();
 
+      KstWriteLocker blockScalarUpdates(&KST::scalarList.lock());
+      KST::scalarList.setUpdateDisplayTags(false);
       for (paramName = parameterName(i);
           !paramName.isEmpty() && i < length;
            paramName = parameterName(++i)) {
         double scalarValue = vectorParam->value(i);
         if (!_outputScalars.contains(paramName)) {
-          KstWriteLocker blockScalarUpdates(&KST::scalarList.lock());
           KstScalarPtr s = new KstScalar(KstObjectTag(paramName, tag()), this, scalarValue);
           s->KstObject::writeLock();  // must write lock, since fit scalars are created from update()
           _outputScalars.insert(paramName, s);
@@ -302,6 +303,7 @@
           _outputScalars[paramName]->setValue(scalarValue);
         }
       }
+      KST::scalarList.setUpdateDisplayTags(true);
     }
   }
 }
--- trunk/extragear/graphics/kst/src/libkstmath/kstcplugin.cpp #631422:631423
@@ -297,15 +297,24 @@
         return setLastUpdateResult(NO_CHANGE);
       }
       KstVectorPtr iv = _inputVectors[(*it)._name];
+      if (!iv) {
+        kstdFatal() << "Input vector \"" << (*it)._name << "\" for plugin " << tag().displayString() << " is invalid." << endl;
+      }
       doUpdate = (UPDATE == iv->update(update_counter)) || doUpdate;
       _inVectors[vitcnt] = iv->value();
       _inArrayLens[vitcnt++] = iv->length();
     } else if ((*it)._type == Plugin::Data::IOValue::FloatType) {
       KstScalarPtr is = _inputScalars[(*it)._name];
+      if (!is) {
+        kstdFatal() << "Input scalar \"" << (*it)._name << "\" for plugin " << tag().displayString() << " is invalid." << endl;
+      }
       doUpdate = (UPDATE == is->update(update_counter)) || doUpdate;
       _inScalars[itcnt++] = is->value();
     } else if ((*it)._type == Plugin::Data::IOValue::StringType) {
       KstStringPtr is = _inputStrings[(*it)._name];
+      if (!is) {
+        kstdFatal() << "Input string \"" << (*it)._name << "\" for plugin " << tag().displayString() << " is invalid." << endl;
+      }
       doUpdate = (UPDATE == is->update(update_counter)) || doUpdate;
       // Maybe we should use UTF-8 instead?
       _inStrings[sitcnt++] = strdup(is->value().latin1());
@@ -664,12 +673,13 @@
       int i = 0;
       int length = vectorParam->length();
 
+      KstWriteLocker blockScalarUpdates(&KST::scalarList.lock());
+      KST::scalarList.setUpdateDisplayTags(false);
       for (paramName = _plugin->parameterName(i); 
           !paramName.isEmpty() && i < length; 
            paramName = _plugin->parameterName(++i)) {
         double scalarValue = vectorParam->value(i);
         if (!_outputScalars.contains(paramName)) {
-          KstWriteLocker blockScalarUpdates(&KST::scalarList.lock());
           KstScalarPtr s = new KstScalar(KstObjectTag(paramName, tag()), this, scalarValue);
           s->KstObject::writeLock();  // must write lock, since fit scalars are created from update()
           _outputScalars.insert(paramName, s);
@@ -678,6 +688,7 @@
           _outputScalars[paramName]->setValue(scalarValue);
         }
       }
+      KST::scalarList.setUpdateDisplayTags(true);
     }
   }
 }


More information about the Kst mailing list