From c020bab0fa05d14b63a813896c7437e2aa9d8a42 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 12 Nov 2013 11:38:52 +0100 Subject: [PATCH] + Make sure to keep order of selected objects in getSelectionEx() --- src/Gui/Selection.cpp | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index cffd9f60a0b1..91f8cea931e5 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -337,25 +337,9 @@ bool SelectionSingleton::hasSelection(const char* doc) const return false; } -//std::vector SelectionSingleton::getSelectionEx(const char* pDocName) const -//{ -// return getSelectionEx(pDocName,App::DocumentObject::getClassTypeId()); -//} -// -//std::vector SelectionSingleton::getSelectionEx(const char* pDocName,const char* typeName) const -//{ -// // search the type -// Base::Type typeId; -// if(typeName) -// typeId = Base::Type::fromName(typeName); -// else -// typeId = App::DocumentObject::getClassTypeId(); -// return getSelectionEx(pDocName,typeId); -//} std::vector SelectionSingleton::getSelectionEx(const char* pDocName, Base::Type typeId) const { std::vector temp; - std::map SortMap; // check the type @@ -398,8 +382,14 @@ std::vector SelectionSingleton::getSelectionEx(const char* pDoc } } - for (std::map::const_iterator It = SortMap.begin();It != SortMap.end();++It) - temp.push_back(It->second); + // The map looses the order thus we have to go again through the list and pick up the SelectionObject from the map + for (std::list<_SelObj>::const_iterator It = _SelList.begin();It != _SelList.end();++It) { + std::map::iterator Jt = SortMap.find(It->pObject); + if (Jt != SortMap.end()) { + temp.push_back(Jt->second); + SortMap.erase(Jt); + } + } return temp; }