App::Document: fix breakDependency
Fixed breakDependency to handle repetitive entries inside PropertyLinkList
This commit is contained in:
@@ -2691,15 +2691,14 @@ void Document::breakDependency(DocumentObject* pcObject, bool clear)
|
||||
link->setValues(std::vector<DocumentObject*>());
|
||||
}
|
||||
else {
|
||||
// copy the list (not the objects)
|
||||
std::vector<DocumentObject*> linked = link->getValues();
|
||||
for (std::vector<DocumentObject*>::iterator fIt = linked.begin(); fIt != linked.end(); ++fIt) {
|
||||
if ((*fIt) == pcObject) {
|
||||
// reassign the the list without the object to be deleted
|
||||
linked.erase(fIt);
|
||||
link->setValues(linked);
|
||||
break;
|
||||
const auto &links = link->getValues();
|
||||
if (std::find(links.begin(), links.end(), pcObject) != links.end()) {
|
||||
std::vector<DocumentObject*> newLinks;
|
||||
for(auto obj : links) {
|
||||
if (obj != pcObject)
|
||||
newLinks.push_back(obj);
|
||||
}
|
||||
link->setValues(newLinks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user