[Kst] branches/work/kst/hierarchy/kst/src/libkstapp
Eli Fidler
eli at staikos.net
Tue Dec 12 17:52:54 CET 2006
SVN commit 612800 by fidler:
better locking
fix plugin tags
M +9 -2 kstdatamanager_i.cpp
M +13 -15 kstplugindialog_i.cpp
--- branches/work/kst/hierarchy/kst/src/libkstapp/kstdatamanager_i.cpp #612799:612800
@@ -663,6 +663,7 @@
for (KstDataObjectList::iterator it = KST::dataObjectList.begin();
it != KST::dataObjectList.end();
++it) {
+ KstReadLocker dol(*it);
bool found = false;
for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
KstObjectItem *oi = static_cast<KstObjectItem*>(i);
@@ -678,13 +679,12 @@
}
}
- KST::matrixList.lock().unlock();
- KST::vectorList.lock().unlock();
KST::dataObjectList.lock().unlock();
// update the data vectors
KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
for (KstRVectorList::iterator it = rvl.begin(); it != rvl.end(); ++it) {
+ KstReadLocker vl(*it);
bool found = false;
for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
KstObjectItem *oi = static_cast<KstObjectItem*>(i);
@@ -703,6 +703,7 @@
// update the static vectors
KstSVectorList svl = kstObjectSubList<KstVector,KstSVector>(KST::vectorList);
for (KstSVectorList::iterator it = svl.begin(); it != svl.end(); ++it) {
+ KstReadLocker vl(*it);
bool found = false;
for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
KstObjectItem *oi = static_cast<KstObjectItem*>(i);
@@ -718,9 +719,12 @@
}
}
+ KST::vectorList.lock().unlock();
+
// update the data matrices
KstRMatrixList rml = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
for (KstRMatrixList::iterator it = rml.begin(); it != rml.end(); ++it) {
+ KstReadLocker ml(*it);
bool found = false;
for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
KstObjectItem *oi = static_cast<KstObjectItem*>(i);
@@ -739,6 +743,7 @@
// update the static matrices
KstSMatrixList sml = kstObjectSubList<KstMatrix,KstSMatrix>(KST::matrixList);
for (KstSMatrixList::iterator it = sml.begin(); it != sml.end(); ++it) {
+ KstReadLocker ml(*it);
bool found = false;
for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
KstObjectItem *oi = static_cast<KstObjectItem*>(i);
@@ -754,6 +759,8 @@
}
}
+ KST::matrixList.lock().unlock();
+
// is this really necessary? I would think not...
for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
if (i == currentItem) {
--- branches/work/kst/hierarchy/kst/src/libkstapp/kstplugindialog_i.cpp #612799:612800
@@ -386,15 +386,15 @@
bool KstPluginDialogI::saveInputs(KstCPluginPtr plugin, KstSharedPtr<Plugin> p) {
bool rc = true;
- KST::vectorList.lock().readLock();
- KST::scalarList.lock().readLock();
- KST::stringList.lock().readLock();
+ KST::scalarList.lock().writeLock();
+ KST::stringList.lock().writeLock();
const QValueList<Plugin::Data::IOValue>& itable = p->data()._inputs;
for (QValueList<Plugin::Data::IOValue>::ConstIterator it = itable.begin(); it != itable.end(); ++it) {
if ((*it)._type == Plugin::Data::IOValue::TableType) {
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "VectorSelector");
assert(field);
VectorSelector *vs = static_cast<VectorSelector*>(field);
+ KstReadLocker vl(&KST::vectorList.lock());
KstVectorPtr v = *KST::vectorList.findTag(vs->selectedVector());
if (v) {
v->writeLock(); // to match with plugin->writeLock()
@@ -410,6 +410,7 @@
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "StringSelector");
assert(field);
StringSelector *ss = static_cast<StringSelector*>(field);
+ KstWriteLocker sl(&KST::stringList.lock());
KstStringPtr s = *KST::stringList.findTag(ss->selectedString());
if (s == *KST::stringList.end()) {
QString val = ss->_string->currentText();
@@ -432,6 +433,7 @@
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "ScalarSelector");
assert(field);
ScalarSelector *ss = static_cast<ScalarSelector*>(field);
+ KstWriteLocker sl(&KST::scalarList.lock());
KstScalarPtr s = *KST::scalarList.findTag(ss->selectedScalar());
if (s == *KST::scalarList.end()) {
bool ok;
@@ -461,9 +463,6 @@
} else {
}
}
- KST::stringList.lock().unlock();
- KST::scalarList.lock().unlock();
- KST::vectorList.lock().unlock();
return rc;
}
@@ -481,11 +480,7 @@
QLineEdit *li = static_cast<QLineEdit*>(field);
if (li->text().isEmpty()) {
- QString tagName = _tagName->text();
- if (tagName==plugin_defaultTag) {
- tagName = plugin->tagName();
- }
- li->setText(tagName + "-" + (*it)._name);
+ li->setText((*it)._name);
}
QString nt = li->text();
@@ -589,6 +584,13 @@
if (pPtr) {
plugin = new KstCPlugin;
plugin->writeLock();
+
+ // set the tag name before any dependents are created
+ if (tagName == plugin_defaultTag) {
+ tagName = KST::suggestPluginName(_pluginList[pitem]);
+ }
+ plugin->setTagName(KstObjectTag(tagName, KstObjectTag::globalTagContext));
+
if (!saveInputs(plugin, pPtr)) {
KMessageBox::sorry(this, i18n("One or more of the inputs was undefined."));
plugin->unlock();
@@ -598,10 +600,6 @@
plugin->setPlugin(pPtr);
- if (tagName == plugin_defaultTag) {
- tagName = KST::suggestPluginName(_pluginList[pitem]);
- }
- plugin->setTagName(KstObjectTag(tagName, KstObjectTag::globalTagContext)); // FIXME: tag context?
if (!saveOutputs(plugin, pPtr)) {
KMessageBox::sorry(this, i18n("One or more of the outputs was undefined."));
plugin->unlock();
More information about the Kst
mailing list