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

Adam Treat treat at kde.org
Thu Aug 30 21:14:03 CEST 2007


SVN commit 706559 by treat:

This is a hack around something we do extensively in Kst
that we can no longer do (and *should* no longer do) in
the future.  Namely, attempt to de-reference a Qt container
iterator that might be QContainer::end()

No more 'KstFooPtr = *_inputVector.find("SOMEFOOTHING");'

For now, I've hacked around this so I can draw a curve without
specifying error bars.  In the future, we'll probably want to
redesign our container classes to make this easier.



 M  +2 -5      libkstapp/plotitem.cpp  
 M  +8 -8      libkstmath/kstvcurve.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #706558:706559
@@ -38,15 +38,12 @@
   KstVectorPtr yTest2 = new KstSVector(-100.0, 100.0, 10000, KstObjectTag::fromString("Y vector 2"));
   yTest2->setLabel("another nice y label");
 
-  KstVectorPtr errorX = new KstSVector(0.0, 0.0, 0, KstObjectTag::fromString("X error"));
-  KstVectorPtr errorY = new KstSVector(0.0, 0.0, 0, KstObjectTag::fromString("y error"));
-
-  KstVCurvePtr renderTest = new KstVCurve(QString("rendertest"), xTest, yTest, errorX, errorY, errorX, errorY, QColor(Qt::red));
+  KstVCurvePtr renderTest = new KstVCurve(QString("rendertest"), xTest, yTest, 0, 0, 0, 0, QColor(Qt::red));
   renderTest->writeLock();
   renderTest->update(0);
   renderTest->unlock();
 
-  KstVCurvePtr renderTest2 = new KstVCurve(QString("rendertest2"), xTest, yTest2, errorX, errorY, errorX, errorY, QColor(Qt::blue));
+  KstVCurvePtr renderTest2 = new KstVCurve(QString("rendertest2"), xTest, yTest2, 0, 0, 0, 0, QColor(Qt::blue));
   renderTest2->writeLock();
   renderTest2->update(0);
   renderTest2->unlock();
--- branches/work/kst/portto4/kst/src/libkstmath/kstvcurve.cpp #706558:706559
@@ -227,22 +227,22 @@
   depUpdated = UPDATE == cxV->update(update_counter) || depUpdated;
   depUpdated = UPDATE == cyV->update(update_counter) || depUpdated;
 
-  KstVectorPtr exV = *_inputVectors.find(EXVECTOR);
+  KstVectorPtr exV = _inputVectors.contains(EXVECTOR) ? *_inputVectors.find(EXVECTOR) : 0;
   if (exV) {
     depUpdated = UPDATE == exV->update(update_counter) || depUpdated;
   }
 
-  KstVectorPtr eyV = *_inputVectors.find(EYVECTOR);
+  KstVectorPtr eyV = _inputVectors.contains(EYVECTOR) ? *_inputVectors.find(EYVECTOR) : 0;
   if (eyV) {
     depUpdated = UPDATE == eyV->update(update_counter) || depUpdated;
   }
 
-  KstVectorPtr exmV = *_inputVectors.find(EXMINUSVECTOR);
+  KstVectorPtr exmV = _inputVectors.contains(EXMINUSVECTOR) ? *_inputVectors.find(EXMINUSVECTOR) : 0;
   if (exmV) {
     depUpdated = UPDATE == exmV->update(update_counter) || depUpdated;
   }
 
-  KstVectorPtr eymV = *_inputVectors.find(EYMINUSVECTOR);
+  KstVectorPtr eymV = _inputVectors.contains(EYMINUSVECTOR) ? *_inputVectors.find(EYMINUSVECTOR) : 0;
   if (eymV) {
     depUpdated = UPDATE == eymV->update(update_counter) || depUpdated;
   }
@@ -1282,10 +1282,10 @@
     b_1 = benchtmp.elapsed();
 #endif
 
-    KstVectorPtr exv = *_inputVectors.find(EXVECTOR);
-    KstVectorPtr eyv = *_inputVectors.find(EYVECTOR);
-    KstVectorPtr exmv = *_inputVectors.find(EXMINUSVECTOR);
-    KstVectorPtr eymv = *_inputVectors.find(EYMINUSVECTOR);
+    KstVectorPtr exv = _inputVectors.contains(EXVECTOR) ? *_inputVectors.find(EXVECTOR) : 0;
+    KstVectorPtr eyv = _inputVectors.contains(EYVECTOR) ? *_inputVectors.find(EYVECTOR) : 0;
+    KstVectorPtr exmv = _inputVectors.contains(EXMINUSVECTOR) ? *_inputVectors.find(EXMINUSVECTOR) : 0;
+    KstVectorPtr eymv = _inputVectors.contains(EYMINUSVECTOR) ? *_inputVectors.find(EYMINUSVECTOR) : 0;
     // draw the bargraph bars, if any...
     if (hasBars()) {
       bool has_top = true;


More information about the Kst mailing list