Make InList hadling and topological sort more robust. fixes #0002871

This commit is contained in:
Stefan Tröger
2017-06-04 14:44:48 +02:00
committed by wmayer
parent 03b63d3a40
commit ab85c6e784
5 changed files with 83 additions and 55 deletions

View File

@@ -75,11 +75,13 @@ void PropertyLink::setValue(App::DocumentObject * lValue)
{
aboutToSetValue();
#ifndef USE_OLD_DAG
// maintain the back link in the DocumentObject class
if(_pcLink)
_pcLink->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
if(lValue)
lValue->_addBackLink(static_cast<DocumentObject*>(getContainer()));
// maintain the back link in the DocumentObject class if it is from a document object
if(getContainer() && getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
if(_pcLink)
_pcLink->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
if(lValue)
lValue->_addBackLink(static_cast<DocumentObject*>(getContainer()));
}
#endif
_pcLink=lValue;
hasSetValue();
@@ -208,10 +210,12 @@ void PropertyLinkList::setValue(DocumentObject* lValue)
{
#ifndef USE_OLD_DAG
//maintain the back link in the DocumentObject class
for(auto *obj : _lValueList)
obj->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
if(lValue)
lValue->_addBackLink(static_cast<DocumentObject*>(getContainer()));
if(getContainer() && getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
for(auto *obj : _lValueList)
obj->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
if(lValue)
lValue->_addBackLink(static_cast<DocumentObject*>(getContainer()));
}
#endif
if (lValue){
@@ -232,10 +236,12 @@ void PropertyLinkList::setValues(const std::vector<DocumentObject*>& lValue)
aboutToSetValue();
#ifndef USE_OLD_DAG
//maintain the back link in the DocumentObject class
for(auto *obj : _lValueList)
obj->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
for(auto *obj : lValue)
obj->_addBackLink(static_cast<DocumentObject*>(getContainer()));
if(getContainer() && getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
for(auto *obj : _lValueList)
obj->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
for(auto *obj : lValue)
obj->_addBackLink(static_cast<DocumentObject*>(getContainer()));
}
#endif
_lValueList = lValue;
hasSetValue();
@@ -391,10 +397,12 @@ void PropertyLinkSub::setValue(App::DocumentObject * lValue, const std::vector<s
{
aboutToSetValue();
#ifndef USE_OLD_DAG
if (_pcLinkSub)
_pcLinkSub->_removeBackLink(static_cast<App::DocumentObject*>(getContainer()));
if (lValue)
lValue->_addBackLink(static_cast<App::DocumentObject*>(getContainer()));
if(getContainer() && getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
if (_pcLinkSub)
_pcLinkSub->_removeBackLink(static_cast<App::DocumentObject*>(getContainer()));
if (lValue)
lValue->_addBackLink(static_cast<App::DocumentObject*>(getContainer()));
}
#endif
_pcLinkSub=lValue;
_cSubList = SubList;
@@ -587,10 +595,12 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue,const char* SubName)
{
#ifndef USE_OLD_DAG
//maintain backlinks
for(auto *obj : _lValueList)
obj->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
if (lValue)
lValue->_addBackLink(static_cast<DocumentObject*>(getContainer()));
if(getContainer() && getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
for(auto *obj : _lValueList)
obj->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
if (lValue)
lValue->_addBackLink(static_cast<DocumentObject*>(getContainer()));
}
#endif
if (lValue) {
@@ -615,15 +625,19 @@ void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& lValue,c
throw Base::ValueError("PropertyLinkSubList::setValues: size of subelements list != size of objects list");
#ifndef USE_OLD_DAG
//maintain backlinks. _lValueList can contain items multiple times, but we trust the document
//object to ensure that this works
for(auto *obj : _lValueList)
obj->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
//maintain backlinks. lValue can contain items multiple times, but we trust the document
//object to ensure that the backlink is only added once
for(auto *obj : lValue)
obj->_addBackLink(static_cast<DocumentObject*>(getContainer()));
//maintain backlinks.
if(getContainer() && getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
//_lValueList can contain items multiple times, but we trust the document
//object to ensure that this works
for(auto *obj : _lValueList)
obj->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
//maintain backlinks. lValue can contain items multiple times, but we trust the document
//object to ensure that the backlink is only added once
for(auto *obj : lValue)
obj->_addBackLink(static_cast<DocumentObject*>(getContainer()));
}
#endif
aboutToSetValue();
@@ -641,15 +655,19 @@ void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& lValue,c
throw Base::ValueError("PropertyLinkSubList::setValues: size of subelements list != size of objects list");
#ifndef USE_OLD_DAG
//maintain backlinks. _lValueList can contain items multiple times, but we trust the document
//object to ensure that this works
for(auto *obj : _lValueList)
obj->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
//maintain backlinks. lValue can contain items multiple times, but we trust the document
//object to ensure that the backlink is only added once
for(auto *obj : lValue)
obj->_addBackLink(static_cast<DocumentObject*>(getContainer()));
//maintain backlinks.
if(getContainer() && getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
//_lValueList can contain items multiple times, but we trust the document
//object to ensure that this works
for(auto *obj : _lValueList)
obj->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
//maintain backlinks. lValue can contain items multiple times, but we trust the document
//object to ensure that the backlink is only added once
for(auto *obj : lValue)
obj->_addBackLink(static_cast<DocumentObject*>(getContainer()));
}
#endif
aboutToSetValue();
@@ -660,16 +678,20 @@ void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& lValue,c
void PropertyLinkSubList::setValue(DocumentObject* lValue, const std::vector<string> &SubList)
{
#ifndef USE_OLD_DAG
//maintain backlinks. _lValueList can contain items multiple times, but we trust the document
//object to ensure that this works
for(auto *obj : _lValueList)
obj->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
//maintain backlinks. lValue can contain items multiple times, but we trust the document
//object to ensure that the backlink is only added once
if(lValue)
lValue->_addBackLink(static_cast<DocumentObject*>(getContainer()));
#ifndef USE_OLD_DAG
//maintain backlinks.
if(getContainer() && getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
//_lValueList can contain items multiple times, but we trust the document
//object to ensure that this works
for(auto *obj : _lValueList)
obj->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
//maintain backlinks. lValue can contain items multiple times, but we trust the document
//object to ensure that the backlink is only added once
if(lValue)
lValue->_addBackLink(static_cast<DocumentObject*>(getContainer()));
}
#endif
aboutToSetValue();