[Kst] branches/work/kst/1.5/kst/src
Andrew Walker
arwalker at sumusltd.com
Fri Jun 29 21:34:42 CEST 2007
SVN commit 681657 by arwalker:
Provide more accurate recursion detection and avoid potential deadlocks
M +1 -1 libkstapp/kstcsddialog_i.cpp
M +1 -1 libkstapp/ksteqdialog_i.cpp
M +2 -1 libkstapp/ksthsdialog_i.cpp
M +2 -1 libkstapp/kstplugindialog_i.cpp
M +1 -1 libkstapp/kstpsddialog_i.cpp
M +22 -32 libkstmath/kstdataobject.cpp
M +7 -10 libkstmath/kstdataobject.h
M +3 -3 libkstmath/ksthistogram.h
--- branches/work/kst/1.5/kst/src/libkstapp/kstcsddialog_i.cpp #681656:681657
@@ -310,9 +310,9 @@
csPtr->setRecursed(false);
if (csPtr->recursion()) {
- KMessageBox::error(this, i18n("There is a recursion resulting from the spectrogram you entered."));
csPtr->setRecursed(true);
csPtr->unlock();
+ KMessageBox::error(this, i18n("There is a recursion resulting from the spectrogram you entered."));
return false;
}
--- branches/work/kst/1.5/kst/src/libkstapp/ksteqdialog_i.cpp #681656:681657
@@ -316,9 +316,9 @@
eqPtr->setRecursed(false);
if (eqPtr->recursion()) {
- KMessageBox::error(this, i18n("There is a recursion resulting from the equation you entered."));
eqPtr->setRecursed(true);
eqPtr->unlock();
+ KMessageBox::error(this, i18n("There is a recursion resulting from the equation you entered."));
return false;
}
}
--- branches/work/kst/1.5/kst/src/libkstapp/ksthsdialog_i.cpp #681656:681657
@@ -357,9 +357,10 @@
hsPtr->setRecursed(false);
if (hsPtr->recursion()) {
- KMessageBox::error(this, i18n("There is a recursion resulting from the histogram you entered."));
+ printf("5\n");
hsPtr->setRecursed(true);
hsPtr->unlock();
+ KMessageBox::error(this, i18n("There is a recursion resulting from the histogram you entered."));
return false;
}
--- branches/work/kst/1.5/kst/src/libkstapp/kstplugindialog_i.cpp #681656:681657
@@ -643,14 +643,15 @@
pp->setRecursed(false);
if (pp->recursion()) {
+ pp->setRecursed(true);
KMessageBox::sorry(this, i18n("There is a recursion resulting from the plugin you entered."));
- pp->setRecursed(true);
return false;
}
pp->setDirty();
emit modified();
+
return true;
}
--- branches/work/kst/1.5/kst/src/libkstapp/kstpsddialog_i.cpp #681656:681657
@@ -329,9 +329,9 @@
psPtr->setRecursed(false);
if (psPtr->recursion()) {
- KMessageBox::error(this, i18n("There is a recursion resulting from the spectrum you entered."));
psPtr->setRecursed(true);
psPtr->unlock();
+ KMessageBox::error(this, i18n("There is a recursion resulting from the spectrum you entered."));
return false;
}
--- branches/work/kst/1.5/kst/src/libkstmath/kstdataobject.cpp #681656:681657
@@ -676,8 +676,8 @@
for (KstScalarMap::ConstIterator j = _inputScalars.begin(); j != _inputScalars.end(); ++j) {
for (; scalarDictIter.current(); ++scalarDictIter) {
if (scalarDictIter.current() == j.data()) {
- return true;
- }
+ return true;
+ }
}
}
} else if (KstMatrixPtr matrix = kst_cast<KstMatrix>(p)) {
@@ -690,8 +690,8 @@
for (KstScalarMap::ConstIterator j = _inputScalars.begin(); j != _inputScalars.end(); ++j) {
for (; scalarDictIter.current(); ++scalarDictIter) {
if (scalarDictIter.current() == j.data()) {
- return true;
- }
+ return true;
+ }
}
}
} else if (KstDataObjectPtr obj = kst_cast<KstDataObject>(p) ) {
@@ -708,11 +708,11 @@
for (; scalarDictIter.current(); ++scalarDictIter) {
if (scalarDictIter.current() == k.data()) {
return true;
- }
+ }
}
}
}
-
+
for (KstMatrixMap::Iterator j = obj->outputMatrices().begin(); j != obj->outputMatrices().end(); ++j) {
for (KstMatrixMap::ConstIterator k = _inputMatrices.begin(); k != _inputMatrices.end(); ++k) {
if (j.data() == k.data()) {
@@ -735,7 +735,7 @@
if (j.data() == k.data()) {
return true;
}
- }
+ }
}
for (KstStringMap::Iterator j = obj->outputStrings().begin(); j != obj->outputStrings().end(); ++j) {
@@ -746,18 +746,24 @@
}
}
}
+
return false;
}
-bool KstDataObject::recursion(KstDataObjectDataObjectMap& objectsToCheck) {
- KstDataObjectDataObjectMap objectsToFollow;
+bool KstDataObject::recursion(KstDataObjectDataObjectMap& objectsInUse) {
bool recurses = false;
- for (KstDataObjectList::ConstIterator it = KST::dataObjectList.begin(); it != KST::dataObjectList.end(); ++it) {
+ objectsInUse.insert(this, this);
+
+ for (KstDataObjectList::Iterator it = KST::dataObjectList.begin(); it != KST::dataObjectList.end(); ++it) {
if ((*it)->uses(this)) {
- if (objectsToCheck.find(*it) == objectsToCheck.end()) {
- objectsToFollow.insert(*it, *it);
+ if (objectsInUse.find(*it) == objectsInUse.end()) {
+ if ((*it)->recursion(objectsInUse)) {
+ recurses = true;
+
+ break;
+ }
} else {
recurses = true;
@@ -766,34 +772,18 @@
}
}
- if (!recurses) {
- for (KstDataObjectDataObjectMap::Iterator j = objectsToFollow.begin(); j != objectsToFollow.end(); ++j) {
- if ((*j)->recursion(objectsToCheck)) {
- recurses = true;
+ objectsInUse.remove(this);
- break;
- }
- objectsToCheck.insert(*j, *j);
- }
- }
-
return recurses;
}
bool KstDataObject::recursion() {
+ KstDataObjectDataObjectMap objectsInUse;
bool recurses = false;
- if (uses(this)) {
- recurses = true;
- } else {
- KstDataObjectDataObjectMap objectsToCheck;
+ recurses = recursion(objectsInUse);
- objectsToCheck.insert(this, this);
-
- recurses = recursion(objectsToCheck);
- }
-
return recurses;
}
@@ -809,4 +799,4 @@
#include "kstdataobject.moc"
-// vim: ts=2 sw=2 et
+
--- branches/work/kst/1.5/kst/src/libkstmath/kstdataobject.h #681656:681657
@@ -76,7 +76,7 @@
const KstStringMap& outputStrings() const { return _outputStrings; }
KstStringMap& inputStrings() { return _inputStrings; }
KstStringMap& outputStrings() { return _outputStrings; }
-
+
const KstMatrixMap& inputMatrices() const { return _inputMatrices; }
const KstMatrixMap& outputMatrices() const { return _outputMatrices; }
KstMatrixMap& inputMatrices() { return _inputMatrices; }
@@ -96,22 +96,22 @@
virtual bool isValid() const;
virtual const KstCurveHintList* curveHints() const;
-
+
virtual bool deleteDependents();
-
+
bool duplicateDependents(KstDataObjectDataObjectMap& duplicatedMap);
-
+
virtual KstDataObjectPtr makeDuplicate(KstDataObjectDataObjectMap& duplicatedMap) = 0;
-
+
virtual void replaceDependency(KstDataObjectPtr oldObject, KstDataObjectPtr newObject);
virtual void replaceDependency(KstVectorPtr oldVector, KstVectorPtr newVector);
virtual void replaceDependency(KstMatrixPtr oldMatrix, KstMatrixPtr newMatrix);
virtual bool uses(KstObjectPtr p) const;
- virtual bool recursion(KstDataObjectDataObjectMap& objectsToCheck);
+ virtual bool recursion(KstDataObjectDataObjectMap& objectsInUse);
virtual bool recursion();
- //These are generally only valid for plugins...
+ // these are generally only valid for plugins...
const QString& name() const { return _name; }
const QString& author() const { return _author; }
const QString& description() const { return _description; }
@@ -125,7 +125,6 @@
virtual void showEditDialog() = 0;
protected:
-
double *vectorRealloced(KstVectorPtr v, double *memptr, int newSize) const;
//The plugin infrastructure will read the desktop file and set these
@@ -170,6 +169,4 @@
static KstDataObjectPtr createPlugin(KService::Ptr);
};
-
#endif
-// vim: ts=2 sw=2 et
--- branches/work/kst/1.5/kst/src/libkstmath/ksthistogram.h #681656:681657
@@ -84,7 +84,7 @@
double vMax() const;
double vMin() const;
int vNumSamples() const;
-
+
virtual KstDataObjectPtr makeDuplicate(KstDataObjectDataObjectMap& duplicatedMap);
private:
@@ -99,7 +99,7 @@
double _Normalization;
double _W;
bool _realTimeAutoBin;
-
+
void commonConstructor(const QString &in_tag, KstVectorPtr in_V,
double xmin_in, double xmax_in,
int in_n_bins,
@@ -111,4 +111,4 @@
typedef KstObjectList<KstHistogramPtr> KstHistogramList;
#endif
-// vim: ts=2 sw=2 et
+
More information about the Kst
mailing list