[Kst] extragear/graphics/kst/src

Adam Treat treat at kde.org
Sat Oct 7 01:14:44 CEST 2006


SVN commit 593166 by treat:

* This is related to the 593145.  I don't like the
param for locking, but I see no way around it.




 M  +1 -1      libkstapp/ksteqdialog_i.cpp  
 M  +15 -3     libkstmath/kstequation.cpp  
 M  +1 -1      libkstmath/kstequation.h  


--- trunk/extragear/graphics/kst/src/libkstapp/ksteqdialog_i.cpp #593165:593166
@@ -291,7 +291,7 @@
   }
   
   if (_equationDirty) {
-    eqPtr->setEquation(_w->_equation->text());
+    eqPtr->setEquation(_w->_equation->text(), true);
     if (!eqPtr->isValid()) {
       QString parseErrors;
       for (QStringList::ConstIterator i = Equation::errorStack.begin(); i != Equation::errorStack.end(); ++i) {
--- trunk/extragear/graphics/kst/src/libkstmath/kstequation.cpp #593165:593166
@@ -25,6 +25,7 @@
 
 // include files for Qt
 #include <qstylesheet.h>
+#include <qdeepcopy.h>
 
 // include files for KDE
 #include <klocale.h>
@@ -262,13 +263,19 @@
 }
 
 
-void KstEquation::setEquation(const QString& in_fn) {
+void KstEquation::setEquation(const QString& in_fn, bool lockData) {
   // assert(*_xVector); - ugly, we have to allow this here due to
   // document loading with vector lazy-loading
   setDirty();
   _equation = in_fn;
   VectorsUsed.clear();
+
+  KstScalarMap::Iterator it = _inputScalars.begin();
+  for (; it != _inputScalars.end(); ++it) {
+    (*it)->unlock();
+  }
   _inputScalars.clear();
+
   _ns = 2; // reset the updating
   delete _pe;
   _pe = 0L;
@@ -285,12 +292,18 @@
       ctx.xVector = *_xInVector;
       Equation::FoldVisitor vis(&ctx, &_pe);
       KstStringMap sm;
+
       if (_pe->collectObjects(VectorsUsed, _inputScalars, sm)) {
+        if (lockData) {
+          KstScalarMap::Iterator it = _inputScalars.begin();
+          for (; it != _inputScalars.end(); ++it) {
+            (*it)->readLock();
+          }
+        }
         _pe->update(-1, &ctx);
       } else {
         //we have bad objects...
         KstDebug::self()->log(i18n("Equation [%1] references non-existent objects.").arg(_equation), KstDebug::Error);
-        _inputScalars.clear();
         delete (Equation::Node*)ParsedEquation;
         ParsedEquation = 0L;
         Equation::mutex().unlock();
@@ -301,7 +314,6 @@
       for (QStringList::ConstIterator i = Equation::errorStack.begin(); i != Equation::errorStack.end(); ++i) {
         KstDebug::self()->log(i18n("Parse Error: %1").arg(*i), KstDebug::Warning);
       }
-      _inputScalars.clear();
       delete (Equation::Node*)ParsedEquation;
       ParsedEquation = 0L;
       Equation::mutex().unlock();
--- trunk/extragear/graphics/kst/src/libkstmath/kstequation.h #593165:593166
@@ -43,7 +43,7 @@
     virtual QString propertyString() const;
 
     /** equations used to edit the vector */
-    void setEquation(const QString &Equation);
+    void setEquation(const QString &Equation, bool lockData = false);
     void setExistingXVector(KstVectorPtr xvector, bool do_interp);
 
     virtual QString equation() const { return _equation; }


More information about the Kst mailing list