Fix _inList tracking in case of link removal
This commit is contained in:
@@ -578,7 +578,11 @@ void DocumentObject::unsetupObject()
|
||||
void App::DocumentObject::_removeBackLink(DocumentObject* rmvObj)
|
||||
{
|
||||
#ifndef USE_OLD_DAG
|
||||
_inList.erase(std::remove(_inList.begin(), _inList.end(), rmvObj), _inList.end());
|
||||
//do not use erase-remove idom, as this erases ALL entries that match. we only want to remove a
|
||||
//single one.
|
||||
auto it = std::find(_inList.begin(), _inList.end(), rmvObj);
|
||||
if(it != _inList.end())
|
||||
_inList.erase(it);
|
||||
#else
|
||||
(void)rmvObj;
|
||||
#endif
|
||||
@@ -587,8 +591,11 @@ void App::DocumentObject::_removeBackLink(DocumentObject* rmvObj)
|
||||
void App::DocumentObject::_addBackLink(DocumentObject* newObj)
|
||||
{
|
||||
#ifndef USE_OLD_DAG
|
||||
if ( std::find(_inList.begin(), _inList.end(), newObj) == _inList.end() )
|
||||
_inList.push_back(newObj);
|
||||
//we need to add all links, even if they are available multiple times. The reason for this is the
|
||||
//removal: If a link loses this object it removes the backlink. If we would have added it only once
|
||||
//this removal would clear the object from the inlist, even though there may be other link properties
|
||||
//from this object that link to us.
|
||||
_inList.push_back(newObj);
|
||||
#else
|
||||
(void)newObj;
|
||||
#endif //USE_OLD_DAG
|
||||
|
||||
Reference in New Issue
Block a user