App::Document: fix breakDependency

Fixed breakDependency to handle repetitive entries inside
PropertyLinkList
This commit is contained in:
Zheng, Lei
2017-06-27 03:38:30 +08:00
committed by wmayer
parent cea242d7fe
commit fdce472b21

View File

@@ -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);
}
}
}