[Kst] extragear/graphics/kst/src

Eli Fidler eli at staikos.net
Thu Mar 1 23:29:02 CET 2007


SVN commit 638419 by fidler:

re-parse equations before editing/viewing


 M  +5 -0      libkstapp/ksteqdialog_i.cpp  
 M  +21 -0     libkstmath/kstequation.cpp  
 M  +2 -0      libkstmath/kstequation.h  


--- trunk/extragear/graphics/kst/src/libkstapp/ksteqdialog_i.cpp #638418:638419
@@ -86,6 +86,11 @@
     return; // shouldn't be needed
   }
 
+  // re-parse to get the latest equation
+  ep->writeLock();
+  ep->reParse();
+  ep->unlock();
+
   ep->readLock();
   _tagName->setText(ep->tagName());
   _w->_equation->setText(ep->equation());
--- trunk/extragear/graphics/kst/src/libkstmath/kstequation.cpp #638418:638419
@@ -230,6 +230,27 @@
 }
 
 
+void KstEquation::reParse() {
+  Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED);
+
+  if (!_equation.isEmpty()) {
+    QMutexLocker ml(&Equation::mutex());
+    yy_scan_string(_equation.latin1());
+    ParsedEquation = 0L;
+    int rc = yyparse();
+    Equation::Node *en = static_cast<Equation::Node*>(ParsedEquation);
+    if (rc == 0 && en) {
+      if (!en->takeVectors(VectorsUsed)) {
+        kstdWarning() << "Equation [" << _equation << "] failed to find its vectors when re-parsing." << endl;
+      }
+      _equation = en->text();
+    }
+    delete en;
+    ParsedEquation = 0L;
+  }
+}
+
+
 void KstEquation::save(QTextStream &ts, const QString& indent) {
   QString l2 = indent + "  ";
   ts << indent << "<equationobject>" << endl;
--- trunk/extragear/graphics/kst/src/libkstmath/kstequation.h #638418:638419
@@ -44,6 +44,8 @@
 
     /** equations used to edit the vector */
     void setEquation(const QString &Equation);
+    void reParse();
+
     void setExistingXVector(KstVectorPtr xvector, bool do_interp);
 
     virtual QString equation() const { return _equation; }


More information about the Kst mailing list