From 73fc672909be08d8aa71d5ee737ada21af401a44 Mon Sep 17 00:00:00 2001 From: DeepSOIC Date: Thu, 5 Apr 2018 02:43:28 +0300 Subject: [PATCH] App: fix py return of propertyLinkSubList fixes #0002602 Now, it won't bunch up same object entries if they are not adjacent. I.e., same object can appear twice and more, for example: [(object1, ('Edge2', 'Edge3')), (object2, ('Edge1',)), (object1, ('Edge4', 'Edge5'))] Complete bunching causes information loss, and it's impossible to fix the bug with keeping the bunching complete. --- src/App/PropertyLinks.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index a89b5343cb..4f51f3f00f 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -894,24 +894,15 @@ std::vector PropertyLinkSubList::getSubListValues() if (_lValueList.size() != _lSubList.size()) throw Base::ValueError("PropertyLinkSubList::getSubListValues: size of subelements list != size of objects list"); - std::map > tmp; for (std::size_t i = 0; i < _lValueList.size(); i++) { App::DocumentObject* link = _lValueList[i]; std::string sub = _lSubList[i]; - if (tmp.find(link) == tmp.end()) { - // make sure to keep the same order as in '_lValueList' - PropertyLinkSubList::SubSet item; - item.first = link; - values.push_back(item); + if (values.size() == 0 || values.back().first != link){ + //new object started, start a new subset. + values.push_back(SubSet(link, std::vector())); } - - tmp[link].push_back(sub); + values.back().second.push_back(sub); } - - for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { - it->second = tmp[it->first]; - } - return values; }