From deeef3297f0914337a4d78c14b5b4dd7179f003c Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 16 Oct 2018 15:32:00 +0300 Subject: [PATCH] Issue #2690: Full update tree on deletion of a folder --- src/ModuleBase/ModuleBase_ITreeNode.h | 5 ++++- src/XGUI/XGUI_DataModel.cpp | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ITreeNode.h b/src/ModuleBase/ModuleBase_ITreeNode.h index c188dd97e..cef49758a 100644 --- a/src/ModuleBase/ModuleBase_ITreeNode.h +++ b/src/ModuleBase/ModuleBase_ITreeNode.h @@ -185,12 +185,13 @@ protected: int aIdx; int aCount = 0; int aSize = myChildren.size(); + int aShift = 0; while (i < aSize) { aCount++; aNode = myChildren.at(i); aObject = aNode->object(); if (aObject.get()) { - aIdx = aObject->document()->index(aObject, true); + aIdx = aObject->document()->index(aObject, true) + aShift; if (aIdx != i) { myChildren.removeAll(aNode); myChildren.insert(aIdx, aNode); @@ -198,6 +199,8 @@ protected: continue; } } + else + aShift++; i++; // To avoid unlimited cycling if (aCount > aSize * aSize) diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 45354a917..4ead852d1 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -88,8 +88,14 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess const std::list, std::string>>& aMsgGroups = aUpdMsg->groups(); std::list, std::string>>::const_iterator aIt; - for (aIt = aMsgGroups.cbegin(); aIt != aMsgGroups.cend(); aIt++) + bool isRebuildTree = false; + for (aIt = aMsgGroups.cbegin(); aIt != aMsgGroups.cend(); aIt++) { + if (aIt->second == ModelAPI_Folder::group()) + isRebuildTree = true; QTreeNodesList aList = myRoot->objectsDeleted(aIt->first, aIt->second.c_str()); + } + if (isRebuildTree) + myRoot->update(); rebuildDataTree(); } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) { -- 2.39.2