Salome HOME
Fix for creation in GUI and unit-test for the issue #2681
[modules/shaper.git] / src / Model / Model_Document.cpp
index d71b770c78c9c06fc6b516595fafb20c5b500245..4d4207648740649aec6d7da1fdad57830da3701d 100755 (executable)
@@ -1000,12 +1000,14 @@ void Model_Document::moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis)
 
 void Model_Document::updateHistory(const std::shared_ptr<ModelAPI_Object> theObject)
 {
-  myObjs->updateHistory(theObject);
+  if (myObjs)
+    myObjs->updateHistory(theObject);
 }
 
 void Model_Document::updateHistory(const std::string theGroup)
 {
-  myObjs->updateHistory(theGroup);
+  if (myObjs)
+    myObjs->updateHistory(theGroup);
 }
 
 const std::set<int> Model_Document::subDocuments() const
@@ -1493,8 +1495,13 @@ bool Model_Document::isLaterByDep(FeaturePtr theThis, FeaturePtr theOther) {
         if (!aRefFeat.get()) { // take feature of the result
           aRefFeat = feature(std::dynamic_pointer_cast<ModelAPI_Result>(aRefObj));
         }
-        if (aRefFeat.get() && aRefFeat == theThis) {
-          return false; // other references to this, so other later than this
+        if (aRefFeat.get()) {
+          if (aRefFeat == theThis)
+            return false; // other references to this, so other later than this
+          if (std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aRefFeat)) {
+            if (!isLaterByDep(theThis, aRefFeat)) // nested composites: recursion
+              return false;
+          }
         }
       }
     }