From e74578c9716318b726a0b4c0c9adcf252d44be6d Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 26 May 2016 11:02:07 +0300 Subject: [PATCH] Issue #1510: Sort group names according to deletion order --- src/XGUI/XGUI_DataModel.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 3fa9d63a5..d1ccd46ff 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -159,8 +159,21 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess std::shared_ptr aUpdMsg = std::dynamic_pointer_cast(theMessage); DocumentPtr aDoc = aUpdMsg->document(); - std::set aGroups = aUpdMsg->groups(); - std::set::const_iterator aIt; + std::set aMsgGroups = aUpdMsg->groups(); + + /// Sort groups because RootType deletion has to be done after others + std::string aType = (aDoc == aRootDoc)? aRootType : aSubType; + std::list aGroups; + std::set::const_iterator aSetIt; + for (aSetIt = aMsgGroups.begin(); aSetIt != aMsgGroups.end(); ++aSetIt) { + std::string aGroup = (*aSetIt); + if (aGroup == aType) + aGroups.push_back(aGroup); + else + aGroups.push_front(aGroup); + } + + std::list::const_iterator aIt; for (aIt = aGroups.begin(); aIt != aGroups.end(); ++aIt) { std::string aGroup = (*aIt); if (aDoc == aRootDoc) { // If root objects -- 2.39.2