[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Tue Mar 16 11:04:20 CET 2004


CVS commit by staikos: 

track down what is perhaps the most difficult bug to find in Kst so far:
can't iteratively lock children and then iteratively unlock them while doing
a loadInputs() in between because the lists are modified in loadInputs()!
The base implementation of the lock should be sufficient in this case since it
only ever happens in KstDoc


  M +15 -0     kstdataobject.cpp   1.24
  M +2 -2      kstdoc.cpp   1.59
  M +1 -0      kstobject.h   1.19


--- kdeextragear-2/kst/kst/kstdataobject.cpp  #1.23:1.24
@@ -21,4 +21,5 @@
 #include "kstdebug.h"
 
+#include <qthread.h>
 #include <qtimer.h>
 
@@ -26,4 +27,6 @@
 #include <klocale.h>
 
+//#define LOCKTRACE
+
 KstDataObject::KstDataObject() : KstObject() {
   //kdDebug() << "+++ CREATING DATA OBJECT: " << (void*)this << endl;
@@ -132,4 +135,7 @@ void KstDataObject::showDialog() {
 void KstDataObject::readLock() const {
   KstObject::readLock();
+  #ifdef LOCKTRACE
+  kdDebug() << "Read lock by tid=" << (int)QThread::currentThread() << endl;
+  #endif
   for (KstScalarMap::ConstIterator i = _inputScalars.begin(); i != _inputScalars.end(); ++i) {
     (*i)->readLock();
@@ -148,4 +154,7 @@ void KstDataObject::readLock() const {
 
 void KstDataObject::readUnlock() const {
+  #ifdef LOCKTRACE
+  kdDebug() << "Read unlock by tid=" << (int)QThread::currentThread() << endl;
+  #endif
   for (KstVectorMap::ConstIterator i = _outputVectors.begin(); i != _outputVectors.end(); ++i) {
     (*i)->readUnlock();
@@ -168,4 +177,7 @@ void KstDataObject::readUnlock() const {
 // Might want to guard these with another lock yet.
 void KstDataObject::writeLock() const {
+  #ifdef LOCKTRACE
+  kdDebug() << "Write lock by tid=" << (int)QThread::currentThread() << endl;
+  #endif
   KstObject::writeLock();
   for (KstScalarMap::ConstIterator i = _inputScalars.begin(); i != _inputScalars.end(); ++i) {
@@ -185,4 +197,7 @@ void KstDataObject::writeLock() const {
 
 void KstDataObject::writeUnlock() const {
+  #ifdef LOCKTRACE
+  kdDebug() << "Write unlock by tid=" << (int)QThread::currentThread() << endl;
+  #endif
   for (KstVectorMap::ConstIterator i = _outputVectors.begin(); i != _outputVectors.end(); ++i) {
     (*i)->writeUnlock();

--- kdeextragear-2/kst/kst/kstdoc.cpp  #1.58:1.59
@@ -261,7 +261,7 @@ bool KstDoc::openDocument(const KURL &ur
        i != KST::dataObjectList.end();
        ++i) {
-    (*i)->writeLock();
+    (*i)->KstObject::writeLock();
     bool rc = (*i)->loadInputs();
-    (*i)->writeUnlock();
+    (*i)->KstObject::writeUnlock();
     if (!rc) {
       // schedule for removal

--- kdeextragear-2/kst/kst/kstobject.h  #1.18:1.19
@@ -66,4 +66,5 @@ private:
 };
 
+typedef KstSharedPtr<KstObject> KstObjectPtr;
 
 #include <qvaluelist.h>





More information about the Kst mailing list