[Kst] kst_threading_branch: kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Fri Jan 9 04:58:13 CET 2004


CVS commit by staikos: 

Add more synchronization, and track down a -nasty- gcc quirk:

template<class T>
class KstObjectList : public QValueList<T>

1 KstObjectList(const QValueList<T>& x)
2 KstObjectList(const KstObjectList<T>& x)

gcc 2.95: Only calls copy constructor #2 (it ignores copy constructors of the
          first form, which are really a typo anyway)
gcc 3.3: Calls either one

Since I had mistyped and used #1, it was crashing in very strange ways on my
gcc 2.95 machine.  Unfortunately no valgrind there. :-)


  M +16 -1     kstdoc.cpp   1.48.2.3
  M +2 -2      kstfilter.h   1.10.2.2
  M +4 -2      kstobject.h   1.14.2.4


--- kdeextragear-2/kst/kst/kstdoc.cpp  #1.48.2.2:1.48.2.3
@@ -219,17 +219,30 @@ bool KstDoc::openDocument(const KURL &ur
         // Vectors are automatically added to the global list.
       } else if (e.tagName() == "filterset") {
+        KST::filterSetList.lock();
         KST::filterSetList.append(new KstFilterSet(e));
+        KST::filterSetList.unlock();
       } else if (e.tagName() == "filteredvector") {
-        KST::vectorList.append(new KstFilteredVector(e));
+        new KstFilteredVector(e);
+        // Vectors are automatically added to the global list.
       } else if (e.tagName() == "plugin") {
+        KST::dataObjectList.lock();
         KST::dataObjectList.append(new KstPlugin(e));
+        KST::dataObjectList.unlock();
       } else if (e.tagName() == "curve") {
+        KST::dataObjectList.lock();
         KST::dataObjectList.append(new KstVCurve(e));
+        KST::dataObjectList.unlock();
       } else if (e.tagName() == "equation") {
+        KST::dataObjectList.lock();
         KST::dataObjectList.append(new KstEquationCurve(e));
+        KST::dataObjectList.unlock();
       } else if (e.tagName() == "psd") {
+        KST::dataObjectList.lock();
         KST::dataObjectList.append(new KstPSDCurve(e));
+        KST::dataObjectList.unlock();
       } else if (e.tagName() == "histogram") {
+        KST::dataObjectList.lock();
         KST::dataObjectList.append(new KstHistogram(e));
+        KST::dataObjectList.unlock();
       } else if (e.tagName() == "plot") {
         KstBaseCurveList l = kstObjectSubList<KstDataObject,KstBaseCurve>(KST::dataObjectList);
@@ -242,4 +255,5 @@ bool KstDoc::openDocument(const KURL &ur
   }
 
+  KST::dataObjectList.lock();
   for (KstDataObjectList::Iterator i = KST::dataObjectList.begin();
        i != KST::dataObjectList.end();
@@ -247,4 +261,5 @@ bool KstDoc::openDocument(const KURL &ur
     (*i)->loadInputs();
   }
+  KST::dataObjectList.unlock();
 
   modified = false;

--- kdeextragear-2/kst/kst/kstfilter.h  #1.10.2.1:1.10.2.2
@@ -57,7 +57,7 @@ class KstFilterSet : public KstObjectLis
 typedef KstSharedPtr<KstFilterSet> KstFilterSetPtr;
 
-class KstFilterSetList : public QValueList<KstFilterSetPtr> {
+class KstFilterSetList : public QValueList<KstFilterSetPtr>, public QMutex {
   public:
-    KstFilterSetList() : QValueList<KstFilterSetPtr>() {}
+    KstFilterSetList() : QValueList<KstFilterSetPtr>(), QMutex(true) {}
     virtual ~KstFilterSetList() {}
 

--- kdeextragear-2/kst/kst/kstobject.h  #1.14.2.3:1.14.2.4
@@ -77,6 +77,6 @@ class KstObjectList : public QValueList<
   public:
     KstObjectList() : QValueList<T>(), _mtx(new QMutex(true)) {}
-    KstObjectList(const QValueList<T>& x) : QValueList<T>(x), _mtx(new QMutex(true)) {}
-    virtual ~KstObjectList() { delete _mtx; }
+    KstObjectList(const KstObjectList<T>& x) : QValueList<T>(x), _mtx(new QMutex(true)) {}
+    virtual ~KstObjectList() { delete _mtx; _mtx = 0L; }
 
     virtual QStringList tagNames() {
@@ -137,4 +137,5 @@ class KstObjectList : public QValueList<
 template<class T, class S>
 KstObjectList<KstSharedPtr<S> > kstObjectSubList(KstObjectList<KstSharedPtr<T> >& list) {
+  list.lock();
   KstObjectList<KstSharedPtr<S> > rc;
   typename KstObjectList<KstSharedPtr<T> >::Iterator it;
@@ -147,4 +148,5 @@ KstObjectList<KstSharedPtr<S> > kstObjec
   }
 
+  list.unlock();
 return rc;
 }





More information about the Kst mailing list