From 8ffcb3215a0a1fb23dc4f3d656efb02e04a93e0c Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Tue, 27 Jun 2017 03:38:30 +0800 Subject: [PATCH] App::Document: fix breakDependency Fixed breakDependency to handle repetitive entries inside PropertyLinkList --- src/App/Document.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 48ec6ea7b8..e119b97407 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -2691,15 +2691,14 @@ void Document::breakDependency(DocumentObject* pcObject, bool clear) link->setValues(std::vector()); } else { - // copy the list (not the objects) - std::vector linked = link->getValues(); - for (std::vector::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 newLinks; + for(auto obj : links) { + if (obj != pcObject) + newLinks.push_back(obj); } + link->setValues(newLinks); } } }