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

George Staikos staikos at kde.org
Wed Feb 25 05:21:58 CET 2004


CVS commit by staikos: 

document loading fixes - now erases objects from kst files if their dependencies
can't be loaded


  M +6 -1      kstdataobject.cpp   1.20.4.2
  M +1 -1      kstdataobject.h   1.22.4.2
  M +15 -1     kstdoc.cpp   1.55.2.3
  M +3 -2      kstequationcurve.cpp   1.47.2.2
  M +1 -1      kstequationcurve.h   1.24.2.2
  M +5 -1      kstvcurve.cpp   1.25.2.3
  M +1 -1      kstvcurve.h   1.17.2.2


--- kdeextragear-2/kst/kst/kstdataobject.cpp  #1.20.4.1:1.20.4.2
@@ -70,5 +70,6 @@ Q_UNUSED(ts);
 }
 
-void KstDataObject::loadInputs() {
+bool KstDataObject::loadInputs() {
+  bool rc = true;
   QValueList<QPair<QString,QString> >::Iterator i;
   KST::vectorList.lock().writeLock();
@@ -79,4 +80,5 @@ void KstDataObject::loadInputs() {
     } else {
       kdWarning() << "Unable to find required vector: " << (*i).second << endl;
+      rc = false;
     }
   }
@@ -90,4 +92,5 @@ void KstDataObject::loadInputs() {
     } else {
       kdWarning() << "Unable to find required scalar: " << (*i).second << endl;
+      rc = false;
     }
   }
@@ -97,4 +100,6 @@ void KstDataObject::loadInputs() {
   _inputScalarLoadQueue.clear();
   update();
+
+  return rc;
 }
 

--- kdeextragear-2/kst/kst/kstdataobject.h  #1.22.4.1:1.22.4.2
@@ -57,5 +57,5 @@ public:
   void showDialog();
 
-  virtual void loadInputs();
+  virtual bool loadInputs();
 
   virtual int getUsage() const;

--- kdeextragear-2/kst/kst/kstdoc.cpp  #1.55.2.2:1.55.2.3
@@ -256,4 +256,5 @@ bool KstDoc::openDocument(const KURL &ur
   }
 
+  KstDataObjectList bitBucket;
   KST::dataObjectList.lock().readLock();
   for (KstDataObjectList::Iterator i = KST::dataObjectList.begin();
@@ -261,8 +262,21 @@ bool KstDoc::openDocument(const KURL &ur
        ++i) {
     (*i)->writeLock();
-    (*i)->loadInputs();
+    bool rc = (*i)->loadInputs();
     (*i)->writeUnlock();
+    if (!rc) {
+      // schedule for removal
+      bitBucket.append(*i);
+    }
   }
   KST::dataObjectList.lock().readUnlock();
+  KST::dataObjectList.lock().writeLock();
+  for (KstDataObjectList::Iterator i = bitBucket.begin(); i != bitBucket.end(); ++i) {
+    KST::dataObjectList.remove(*i);
+  }
+  KST::dataObjectList.lock().writeUnlock();
+
+  if (!bitBucket.isEmpty()) {
+    KMessageBox::sorry(0L, i18n("The data file could not be loaded in entirety due to missing objects or data."));
+  }
 
   modified = false;

--- kdeextragear-2/kst/kst/kstequationcurve.cpp  #1.47.2.1:1.47.2.2
@@ -148,9 +148,10 @@ KstEquationCurve::~KstEquationCurve() {
 
 
-void KstEquationCurve::loadInputs() {
+bool KstEquationCurve::loadInputs() {
   if (!_staticX) {
-    KstDataObject::loadInputs();
+    return KstDataObject::loadInputs();
   } else {
     update();
+    return true;
   }
 }

--- kdeextragear-2/kst/kst/kstequationcurve.h  #1.24.2.1:1.24.2.2
@@ -73,5 +73,5 @@ public:
   virtual void setTagName(const QString& tag);
 
-  virtual void loadInputs();
+  virtual bool loadInputs();
 
 protected:

--- kdeextragear-2/kst/kst/kstvcurve.cpp  #1.25.2.2:1.25.2.3
@@ -96,5 +96,5 @@ void KstVCurve::commonConstructor(const 
 
 
-void KstVCurve::loadInputs() {
+bool KstVCurve::loadInputs() {
   QValueList<QPair<QString,QString> >::Iterator i;
   KST::vectorList.lock().readLock();
@@ -114,8 +114,10 @@ void KstVCurve::loadInputs() {
   if (!VX.data()) {
       kdWarning() << "Unable to find required X vector!" << endl;
+      return false;
   }
 
   if (!VY.data()) {
       kdWarning() << "Unable to find required Y vector!" << endl;
+      return false;
   }
 
@@ -137,4 +139,6 @@ void KstVCurve::loadInputs() {
     EY->readUnlock();
   }
+
+  return true;
 }
 

--- kdeextragear-2/kst/kst/kstvcurve.h  #1.17.2.1:1.17.2.2
@@ -67,5 +67,5 @@ public:
   virtual KstCurveType type() const;
 
-  virtual void loadInputs();
+  virtual bool loadInputs();
 
   virtual bool xIsRising() const {return VX->isRising(); }





More information about the Kst mailing list