[Kst] branches/work/kst/portto4/kst/src

Peter Kümmel syntheticpp at gmx.net
Sat Sep 4 20:08:45 CEST 2010


SVN commit 1171626 by kuemmel:

don't crash on NULL pointers

 M  +18 -2     libkstmath/equation.cpp  
 M  +3 -0      widgets/vectorselector.cpp  


--- branches/work/kst/portto4/kst/src/libkstmath/equation.cpp #1171625:1171626
@@ -185,7 +185,9 @@
     ParsedEquation = 0L;
   }
 
+  if (_xInVector) {
   s.writeAttribute("xvector", _xInVector->Name());
+  }
   if (_doInterp) {
     s.writeAttribute("interpolate", "true");
   }
@@ -248,13 +250,16 @@
 }
 
 void Equation::updateVectorLabels() {
+  if (!_xInVector) {
+    return;
+  }
   QString yl;
   QString xl;
   QRegExp sn("(\\(V(\\d{1,2})\\))|\\[|\\]"); // short name
   yl = reparsedEquation();
   yl.replace(sn,"");
 
-  xl = vXIn()->label();
+  xl = _xInVector->label();
 
   _xOutVector->setLabel(xl);
   _yOutVector->setLabel(yl);
@@ -262,6 +267,10 @@
 }
 
 void Equation::setExistingXVector(VectorPtr in_xv, bool do_interp) {
+  if (!in_xv) {
+    return;
+  }
+
   VectorPtr v = _inputVectors[XINVECTOR];
   if (v == in_xv) {
     return;
@@ -308,6 +317,10 @@
 /*                                                                      */
 /************************************************************************/
 bool Equation::FillY(bool force) {
+  if (!_xInVector) {
+    return false;
+  }
+
   int v_shift=0, v_new;
   int i0=0;
   int ns;
@@ -595,8 +608,11 @@
 }
 
 QString Equation::descriptionTip() const {
-  return i18n("Equation: %1\n  %2\nX: %3").arg(Name()).arg(equation()).arg(vXIn()->descriptionTip());
+  if(!_xInVector) {
+    return QString();
 }
+  return i18n("Equation: %1\n  %2\nX: %3").arg(Name()).arg(equation()).arg(_xInVector->descriptionTip());
+}
 
 }
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/widgets/vectorselector.cpp #1171625:1171626
@@ -79,6 +79,9 @@
 
 
 void VectorSelector::setSelectedVector(VectorPtr selectedVector) {
+  if (!selectedVector) {
+    return;
+  }
   // "findData can't work here" says the trolls... so we do it 'manually'.
   //int i = _vector->findData(qVariantFromValue(selectedVector.data()));
   int i=-1,j;


More information about the Kst mailing list