[Kst] branches/work/kst/pluginify/kst/src/plugins/linefit
Adam Treat
treat at kde.org
Tue Sep 12 18:04:14 CEST 2006
SVN commit 583550 by treat:
* resolve invalid reads and a double deletion. valgrind
is my friend :)
* don't update like crazy. the original plugin didn't behave
like that... not sure if this is what isValid() is meant though...
M +14 -2 linefitplugin.cpp
M +4 -1 linefitplugin.h
--- branches/work/kst/pluginify/kst/src/plugins/linefit/linefitplugin.cpp #583549:583550
@@ -37,12 +37,21 @@
LineFit::LineFit( QObject */*parent*/, const char */*name*/, const QStringList &/*args*/ )
: KstDataObject() {
+ m_init = false;
}
LineFit::~LineFit() {
}
+bool LineFit::isValid() const {
+ return m_init;
+}
+
KstObject::UpdateType LineFit::update(int updateCounter) {
+ if (isValid()) {
+ return setLastUpdateResult(NO_CHANGE);
+ }
+
bool force = dirty();
setDirty(false);
@@ -63,6 +72,9 @@
depUpdated = UPDATE == yIn->update(updateCounter) || depUpdated;
linefit();
+
+ m_init = true;
+
setLastUpdateResult(UPDATE); // make sure that provider callbacks work
KstVectorPtr xOut = *_outputVectors.find(X_COORDINATES_OUT);
@@ -109,10 +121,10 @@
}
if (xOut->length() != 2) {
- vectorRealloced(xOut, xOut->value(), 2);
+ xOut->resize( 2, false );
}
if (yOut->length() != 2) {
- vectorRealloced(yOut, yOut->value(), 2);
+ yOut->resize( 2, false );
}
if (yIn->length() == 1) {
--- branches/work/kst/pluginify/kst/src/plugins/linefit/linefitplugin.h #583549:583550
@@ -52,7 +52,7 @@
// virtual void writeLock() const;
// virtual void unlock() const;
//
-// virtual bool isValid() const;
+ virtual bool isValid() const;
//
// virtual const KstCurveHintList* curveHints() const;
//
@@ -68,6 +68,9 @@
//Pure virtual slots from KstDataObject
virtual void _showDialog();
+private:
+ bool m_init;
+
};
#endif
More information about the Kst
mailing list