]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Correct setting folder sub-elements on document opening
authorazv <azv@opencascade.com>
Tue, 28 Nov 2017 13:24:09 +0000 (16:24 +0300)
committerazv <azv@opencascade.com>
Tue, 28 Nov 2017 13:24:09 +0000 (16:24 +0300)
src/Model/Model_Objects.cpp
src/ModelAPI/ModelAPI_Folder.cpp
src/PartSet/PartSet_Tools.h

index 7324960c650a448bab7a7845a518116d4de3b45e..0f3b779f43aaa535d84239cc3ce826f1f4b673a8 100644 (file)
@@ -957,7 +957,10 @@ void Model_Objects::synchronizeBackRefsForObject(const std::set<AttributePtr>& t
   for(; aNewIter != theNewRefs.end(); aNewIter++) {
     if (aData->refsToMe().find(*aNewIter) == aData->refsToMe().end()) {
       FeaturePtr aRefFeat = std::dynamic_pointer_cast<ModelAPI_Feature>((*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
index 9655293740f67bc3fba3485c963b8d2ad6bde62b..1cc97cb366036f7aa5648ec91b0fdd6b14e34594 100644 (file)
@@ -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()
index 486d361e01cdb6d30461f5fd587858973c176306..1a8beb6703ecde71c7df961411e7d564707e934b 100755 (executable)
@@ -256,7 +256,7 @@ public:
     std::set<AttributePtr>::const_iterator anIt;
     for (anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) {
       FeaturePtr aRefFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*anIt)->owner());
-      if (aRefFeature->getKind() == theFeatureId)
+      if (aRefFeature && aRefFeature->getKind() == theFeatureId)
         return aRefFeature;
     }
     return FeaturePtr();