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

Eli Fidler eli at staikos.net
Thu Feb 8 00:24:19 CET 2007


SVN commit 631418 by fidler:

better error checking


 M  +34 -4     kstdataobject.cpp  


--- trunk/extragear/graphics/kst/src/libkstmath/kstdataobject.cpp #631417:631418
@@ -385,16 +385,22 @@
   while (inputIt != inputs.end() || outputIt != outputs.end()) {
     if (inputIt != inputs.end() && (outputIt == outputs.end() || (void*)(*inputIt) < (void*)(*outputIt))) {
       // do input
-      #ifdef LOCKTRACE
+      if (!(*inputIt)) {
+        kstdFatal() << "Input for data object " << this->tag().displayString() << " is invalid." << endl;
+      }
+#ifdef LOCKTRACE
       kstdDebug() << (void*)this << " (" << this->type() << ": " << this->tag().tagString() << ") KstDataObject::writeLockInputsAndOutputs() by tid=" << (int)QThread::currentThread() << ": write locking input \"" << (*inputIt)->tag().tagString() << "\" (" << (void*)((KstRWLock*)*inputIt) << ")" << endl;
-      #endif
+#endif
       (*inputIt)->writeLock();
       ++inputIt;
     } else {
       // do output
-      #ifdef LOCKTRACE
+      if (!(*outputIt)) {
+        kstdFatal() << "Output for data object " << this->tag().displayString() << " is invalid." << endl;
+      }
+#ifdef LOCKTRACE
       kstdDebug() << (void*)this << " (" << this->type() << ": " << this->tag().tagString() << ") KstDataObject::writeLockInputsAndOutputs() by tid=" << (int)QThread::currentThread() << ": write locking output \"" << (*outputIt)->tag().tagString() << "\" (" << (void*)((KstRWLock*)*outputIt) << ")" << endl;
-      #endif
+#endif
       if ((*outputIt)->provider() != this) {
         KstDebug::self()->log(i18n("(%1) KstDataObject::writeLockInputsAndOutputs() by tid=%2: write locking output %3 (not provider) -- this is probably an error. Please email kst at kde.org with details.").arg(this->type()).arg((int)QThread::currentThread()).arg((*outputIt)->tagName()), KstDebug::Error);
       }
@@ -411,6 +417,9 @@
   #endif
 
   for (KstMatrixMap::ConstIterator i = _outputMatrices.begin(); i != _outputMatrices.end(); ++i) {
+    if (!(*i)) {
+      kstdFatal() << "Output matrix for data object " << this->tag().displayString() << " is invalid." << endl;
+    }
     #ifdef LOCKTRACE
     kstdDebug() << (void*)this << " (" << this->type() << ": " << this->tag().tagString() << ") KstDataObject::unlockInputsAndOutputs() by tid=" << (int)QThread::currentThread() << ": unlocking output matrix \"" << (*i)->tag().tagString() << "\" (" << (void*)((KstRWLock*)*i) << ")" << endl;
     #endif
@@ -418,6 +427,9 @@
   }
 
   for (KstMatrixMap::ConstIterator i = _inputMatrices.begin(); i != _inputMatrices.end(); ++i) {
+    if (!(*i)) {
+      kstdFatal() << "Input matrix for data object " << this->tag().displayString() << " is invalid." << endl;
+    }
     #ifdef LOCKTRACE
     kstdDebug() << (void*)this << " (" << this->type() << ": " << this->tag().tagString() << ") KstDataObject::unlockInputsAndOutputs() by tid=" << (int)QThread::currentThread() << ": unlocking input matrix \"" << (*i)->tag().tagString() << "\" (" << (void*)((KstRWLock*)*i) << ")" << endl;
     #endif
@@ -425,6 +437,9 @@
   }
 
   for (KstVectorMap::ConstIterator i = _outputVectors.begin(); i != _outputVectors.end(); ++i) {
+    if (!(*i)) {
+      kstdFatal() << "Output vector for data object " << this->tag().displayString() << " is invalid." << endl;
+    }
     #ifdef LOCKTRACE
     kstdDebug() << (void*)this << " (" << this->type() << ": " << this->tag().tagString() << ") KstDataObject::unlockInputsAndOutputs() by tid=" << (int)QThread::currentThread() << ": unlocking output vector \"" << (*i)->tag().tagString() << "\" (" << (void*)((KstRWLock*)*i) << ")" << endl;
     #endif
@@ -432,6 +447,9 @@
   }
 
   for (KstVectorMap::ConstIterator i = _inputVectors.begin(); i != _inputVectors.end(); ++i) {
+    if (!(*i)) {
+      kstdFatal() << "Input vector for data object " << this->tag().displayString() << " is invalid." << endl;
+    }
     #ifdef LOCKTRACE
     kstdDebug() << (void*)this << " (" << this->type() << ": " << this->tag().tagString() << ") KstDataObject::unlockInputsAndOutputs() by tid=" << (int)QThread::currentThread() << ": unlocking input vector \"" << (*i)->tag().tagString() << "\" (" << (void*)((KstRWLock*)*i) << ")" << endl;
     #endif
@@ -439,6 +457,9 @@
   }
 
   for (KstScalarMap::ConstIterator i = _outputScalars.begin(); i != _outputScalars.end(); ++i) {
+    if (!(*i)) {
+      kstdFatal() << "Output scalar for data object " << this->tag().displayString() << " is invalid." << endl;
+    }
     #ifdef LOCKTRACE
     kstdDebug() << (void*)this << " (" << this->type() << ": " << this->tag().tagString() << ") KstDataObject::unlockInputsAndOutputs() by tid=" << (int)QThread::currentThread() << ": unlocking output scalar \"" << (*i)->tag().tagString() << "\" (" << (void*)((KstRWLock*)*i) << ")" << endl;
     #endif
@@ -446,6 +467,9 @@
   }
 
   for (KstScalarMap::ConstIterator i = _inputScalars.begin(); i != _inputScalars.end(); ++i) {
+    if (!(*i)) {
+      kstdFatal() << "Input scalar for data object " << this->tag().displayString() << " is invalid." << endl;
+    }
     #ifdef LOCKTRACE
     kstdDebug() << (void*)this << " (" << this->type() << ": " << this->tag().tagString() << ") KstDataObject::unlockInputsAndOutputs() by tid=" << (int)QThread::currentThread() << ": unlocking input scalar \"" << (*i)->tag().tagString() << "\" (" << (void*)((KstRWLock*)*i) << ")" << endl;
     #endif
@@ -453,6 +477,9 @@
   }
 
   for (KstStringMap::ConstIterator i = _outputStrings.begin(); i != _outputStrings.end(); ++i) {
+    if (!(*i)) {
+      kstdFatal() << "Output string for data object " << this->tag().displayString() << " is invalid." << endl;
+    }
    #ifdef LOCKTRACE
     kstdDebug() << (void*)this << " (" << this->type() << ": " << this->tag().tagString() << ") KstDataObject::unlockInputsAndOutputs() by tid=" << (int)QThread::currentThread() << ": unlocking output string \"" << (*i)->tag().tagString() << "\" (" << (void*)((KstRWLock*)*i) << ")" << endl;
     #endif
@@ -460,6 +487,9 @@
   }
 
   for (KstStringMap::ConstIterator i = _inputStrings.begin(); i != _inputStrings.end(); ++i) {
+    if (!(*i)) {
+      kstdFatal() << "Input string for data object " << this->tag().displayString() << " is invalid." << endl;
+    }
     #ifdef LOCKTRACE
     kstdDebug() << (void*)this << " (" << this->type() << ": " << this->tag().tagString() << ") KstDataObject::unlockInputsAndOutputs() by tid=" << (int)QThread::currentThread() << ": unlocking input string \"" << (*i)->tag().tagString() << "\" (" << (void*)((KstRWLock*)*i) << ")" << endl;
     #endif


More information about the Kst mailing list