From 90e8d13429461dc1ddd4b568b7e1fa3975f7193e Mon Sep 17 00:00:00 2001 From: jfa Date: Tue, 2 Nov 2021 18:14:28 +0300 Subject: [PATCH] [bos #24727] [CEA] Selection mechanism not working on a re-opened study --- src/Model/Model_AttributeSelection.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 9f48443fa..787492492 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -2012,6 +2012,23 @@ bool Model_AttributeSelection::restoreContext(std::wstring theName, } } + // Fix for opened study (aDoc->myNamingNames is empty) + if (theValue.IsNull() && aCont->groupName() != ModelAPI_ResultConstruction::group()) { + std::wstring::size_type aSlash = aSubShapeName.rfind(L'/'); + if (aSlash != std::wstring::npos) { + std::wstring aCompName = aSubShapeName.substr(aSlash + 1); + TDF_Label aLab = std::dynamic_pointer_cast(aCont->data())->shapeLab(); + TDF_ChildIDIterator aSubNames (aLab, TDataStd_Name::GetID()); + for (; aSubNames.More(); aSubNames.Next()) { + if (Handle(TDataStd_Name)::DownCast(aSubNames.Value())->Get().IsEqual(aCompName.c_str())) { + theValue = aSubNames.Value()->Label(); + aDoc->addNamingName(theValue, aSubShapeName); + break; + } + } + } + } + if (aCont.get()) { theContext = std::dynamic_pointer_cast(aCont->data())->label(); } -- 2.39.2