From: azv Date: Tue, 28 Nov 2017 13:24:09 +0000 (+0300) Subject: Correct setting folder sub-elements on document opening X-Git-Tag: V_2.10.0RC~123^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3a630d6e7cc711d5c322271735e711fa5197892c;p=modules%2Fshaper.git Correct setting folder sub-elements on document opening --- diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 7324960c6..0f3b779f4 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -957,7 +957,10 @@ void Model_Objects::synchronizeBackRefsForObject(const std::set& t for(; aNewIter != theNewRefs.end(); aNewIter++) { if (aData->refsToMe().find(*aNewIter) == aData->refsToMe().end()) { FeaturePtr aRefFeat = std::dynamic_pointer_cast((*aNewIter)->owner()); - aData->addBackReference(aRefFeat, (*aNewIter)->id()); + if (aRefFeat) + aData->addBackReference(aRefFeat, (*aNewIter)->id()); + else // add back reference to a folder + aData->addBackReference((*aNewIter)->owner(), (*aNewIter)->id()); } } if (theNewRefs.size() != aData->refsToMe().size()) { // some back ref must be removed diff --git a/src/ModelAPI/ModelAPI_Folder.cpp b/src/ModelAPI/ModelAPI_Folder.cpp index 965529374..1cc97cb36 100644 --- a/src/ModelAPI/ModelAPI_Folder.cpp +++ b/src/ModelAPI/ModelAPI_Folder.cpp @@ -38,9 +38,6 @@ void ModelAPI_Folder::initAttributes() { data()->addAttribute(FIRST_FEATURE_ID(), ModelAPI_AttributeReference::typeId()); data()->addAttribute(LAST_FEATURE_ID(), ModelAPI_AttributeReference::typeId()); - // nullify references for sure - reference(FIRST_FEATURE_ID())->setValue(ObjectPtr()); - reference(LAST_FEATURE_ID())->setValue(ObjectPtr()); } void ModelAPI_Folder::execute() diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index 486d361e0..1a8beb670 100755 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -256,7 +256,7 @@ public: std::set::const_iterator anIt; for (anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) { FeaturePtr aRefFeature = std::dynamic_pointer_cast((*anIt)->owner()); - if (aRefFeature->getKind() == theFeatureId) + if (aRefFeature && aRefFeature->getKind() == theFeatureId) return aRefFeature; } return FeaturePtr();