[Kst] extragear/graphics/kst/src/libkstapp

Adam Treat treat at kde.org
Tue Apr 3 20:15:27 CEST 2007


SVN commit 650056 by treat:

* Fix for deadlock

BUG:134499


 M  +6 -2      ksteventmonitor_i.cpp  
 M  +6 -8      ksteventmonitorentry.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/ksteventmonitor_i.cpp #650055:650056
@@ -187,15 +187,19 @@
   }
 
   EventMonitorEntryPtr event = new EventMonitorEntry(tag_name);
+  event->writeLock();
   fillEvent(event);
 
   if (!event->isValid()) {
+    event->unlock();
     event = 0L;
 
     KMessageBox::sorry(this, i18n("There is a syntax error in the equation you entered."));
     return false;
   }
 
+  event->unlock();
+
   KST::dataObjectList.lock().writeLock();
   KST::dataObjectList.append(event.data());
   KST::dataObjectList.lock().unlock();
@@ -255,10 +259,10 @@
   } else if (_w->radioButtonLogError->isChecked()) {
     emPtr->setLevel(KstDebug::Error);
   }
-  
+
   emPtr->reparse();
   emPtr->unlock();
-  
+
   return true;
 }
 
--- trunk/extragear/graphics/kst/src/libkstapp/ksteventmonitorentry.cpp #650055:650056
@@ -118,6 +118,7 @@
 
 
 bool EventMonitorEntry::reparse() {
+  Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED);
   _isValid = false;
   if (!_event.isEmpty()) {
     QMutexLocker ml(&Equation::mutex());
@@ -128,15 +129,12 @@
       Equation::Context ctx;
       Equation::FoldVisitor vis(&ctx, &_pExpression);
       KstStringMap stm;
-      _pExpression->collectObjects(_vectorsUsed, _inputScalars, stm);
-
-      for (KstScalarMap::ConstIterator i = _inputScalars.begin(); i != _inputScalars.end(); ++i) {
-        if ((*i)->myLockStatus() == KstRWLock::UNLOCKED) {
-          (*i)->readLock();
-        }
-      }
-
+      if (_pExpression->collectObjects(_vectorsUsed, _inputScalars, stm)) {
       _isValid = true;
+      } else {
+        //we have bad objects...
+        delete (Equation::Node*)ParsedEquation;
+      }
     } else {
       delete (Equation::Node*)ParsedEquation;
     }


More information about the Kst mailing list