From 48c727855d1b0cc508434a3a4267a7bd0732c55d Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 23 Nov 2017 11:56:02 +0300 Subject: [PATCH] Update history for the objects outside of the folder --- src/Model/Model_Objects.cpp | 14 +++++++++----- src/ModelAPI/Test/TestFolder_Create.py | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 1eb9349d5..1d37ddeea 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -392,9 +392,8 @@ void Model_Objects::clearHistory(ObjectPtr theObj) { if (theObj.get()) { const std::string aGroup = theObj->groupName(); - std::map >::iterator aHIter = myHistory.find(aGroup); - if (aHIter != myHistory.end()) - myHistory.erase(aHIter); // erase from map => this means that it is not synchronized + updateHistory(aGroup); + if (theObj->groupName() == ModelAPI_Feature::group()) { // clear results group of the feature FeaturePtr aFeature = std::dynamic_pointer_cast(theObj); std::string aResultGroup = featureResultGroup(aFeature); @@ -457,7 +456,7 @@ void Model_Objects::createHistory(const std::string& theGroupID) // it may be a folder ObjectPtr aFolder = folder(aRefs->Value(a)); if (aFolder.get()) { - aResult.push_back(aFolder); + aResultOutOfFolder.push_back(aFolder); // get the last feature in the folder AttributeReferencePtr aLastFeatAttr = @@ -487,8 +486,13 @@ void Model_Objects::updateHistory(const std::shared_ptr theObje void Model_Objects::updateHistory(const std::string theGroup) { std::map >::iterator aHIter = myHistory.find(theGroup); - if (aHIter != myHistory.end()) + if (aHIter != myHistory.end()) { myHistory.erase(aHIter); // erase from map => this means that it is not synchronized + + // erase history for the group of objects placed out of any folder + const std::string& anOutOfFolderGroupID = groupNameFoldering(theGroup, true); + myHistory.erase(anOutOfFolderGroupID); + } } ObjectPtr Model_Objects::folder(TDF_Label theLabel) const diff --git a/src/ModelAPI/Test/TestFolder_Create.py b/src/ModelAPI/Test/TestFolder_Create.py index a46b964d5..492e73f1e 100644 --- a/src/ModelAPI/Test/TestFolder_Create.py +++ b/src/ModelAPI/Test/TestFolder_Create.py @@ -96,7 +96,7 @@ aSession.finishOperation() assert(aPartDoc.size("Folders") == 1) FOLDER_NAME_EXPECTED = "Folder_1" -assert(aFolder1.name() == FOLDER_NAME_EXPECTED), "Actual name '{}', expected '{}'".format(aFolder1.name(), FOLDER_NAME_EXPECTED) +assert(aFolder2.name() == FOLDER_NAME_EXPECTED), "Actual name '{}', expected '{}'".format(aFolder2.name(), FOLDER_NAME_EXPECTED) from salome.shaper import model assert(model.checkPythonDump()) -- 2.39.2