]> OCCT Git - occt-copy.git/commitdiff
0030341: Unset child/parent links bugs fix CR30341
authorsnn <snn@opencascade.com>
Tue, 6 Nov 2018 13:19:46 +0000 (16:19 +0300)
committersnn <snn@opencascade.com>
Wed, 7 Nov 2018 11:04:33 +0000 (14:04 +0300)
src/XCAFDoc/XCAFDoc_GraphNode.cxx

index 0e904a6c0cf40ad417937d8860ba7c548e0147e8..5373293c39503b2f4c86535ec7dbbb06ffcd9a27 100644 (file)
@@ -93,7 +93,6 @@ XCAFDoc_GraphNode::XCAFDoc_GraphNode ()
 { 
 }  
 
-
 //=======================================================================
 //function : SetGraphID
 //purpose  : 
@@ -105,8 +104,6 @@ void XCAFDoc_GraphNode::SetGraphID (const Standard_GUID& explicitID)
   myGraphID = explicitID;
 }
 
-
-
 //=======================================================================
 //function : SetFather
 //purpose  : 
@@ -142,8 +139,10 @@ void XCAFDoc_GraphNode::UnSetFather(const Handle(XCAFDoc_GraphNode)& F)
 {
   Standard_Integer Findex = FatherIndex(F);
   if (Findex != 0)
-  F->UnSetChildlink(this);
-  UnSetFatherlink(F);
+  {
+    F->UnSetChildlink(this);
+    UnSetFatherlink(F);
+  }
 }
 
 
@@ -155,10 +154,11 @@ void XCAFDoc_GraphNode::UnSetFather(const Handle(XCAFDoc_GraphNode)& F)
 void XCAFDoc_GraphNode::UnSetFather(const Standard_Integer Findex) 
 {
   if (Findex != 0)
-  UnSetFather( GetFather(Findex) );
+  {
+    UnSetFather( GetFather(Findex) );
+  }
 }
 
-
 //=======================================================================
 //function : UnSetFatherlink
 //purpose  : Remove link finily
@@ -167,7 +167,11 @@ void XCAFDoc_GraphNode::UnSetFather(const Standard_Integer Findex)
 void XCAFDoc_GraphNode::UnSetFatherlink(const Handle(XCAFDoc_GraphNode)& F) 
 {
   Backup();
-  myFathers.Remove( FatherIndex(F) );
+  Standard_Integer Findex = FatherIndex(F);
+  if (Findex != 0)
+  {
+    myFathers.Remove(Findex);
+  }
 }
 
 //=======================================================================
@@ -178,12 +182,13 @@ void XCAFDoc_GraphNode::UnSetFatherlink(const Handle(XCAFDoc_GraphNode)& F)
 void XCAFDoc_GraphNode::UnSetChild(const Handle(XCAFDoc_GraphNode)& Ch) 
 {
   Standard_Integer Chindex = ChildIndex(Ch);
-  if (Chindex != 0) 
-  Ch->UnSetFatherlink(this);
-  UnSetChildlink(Ch);
+  if (Chindex != 0)
+  {
+    Ch->UnSetFatherlink(this);
+    UnSetChildlink(Ch);
+  }
 }
 
-
 //=======================================================================
 //function : UnSetChild
 //purpose  : 
@@ -191,11 +196,12 @@ void XCAFDoc_GraphNode::UnSetChild(const Handle(XCAFDoc_GraphNode)& Ch)
 
  void XCAFDoc_GraphNode::UnSetChild(const Standard_Integer Chindex) 
 {
-  if (Chindex != 0 )
-  UnSetChild( GetChild(Chindex) );
+  if (Chindex != 0)
+  {
+    UnSetChild( GetChild(Chindex) );
+  }
 }
 
-
 //=======================================================================
 //function : UnSetChildlink
 //purpose  : Remove link finily
@@ -204,7 +210,11 @@ void XCAFDoc_GraphNode::UnSetChild(const Handle(XCAFDoc_GraphNode)& Ch)
 void XCAFDoc_GraphNode::UnSetChildlink(const Handle(XCAFDoc_GraphNode)& Ch) 
 {
   Backup();
-  myChildren.Remove( ChildIndex(Ch) );
+  Standard_Integer Chindex = ChildIndex(Ch);
+  if (Chindex != 0)
+  {
+    myChildren.Remove(Chindex);
+  }
 }
 
 //=======================================================================
@@ -348,7 +358,9 @@ void XCAFDoc_GraphNode::Paste(const Handle(TDF_Attribute)& into,
     if (!RT->HasRelocation(myFathers(i), func) && RT->AfterRelocate()) {
       func.Nullify();
     }
-    intof->SetFather(func);
+    if (!func.IsNull()) {
+      intof->SetFather(func);
+    }
   }
 
   i = 1;
@@ -356,7 +368,9 @@ void XCAFDoc_GraphNode::Paste(const Handle(TDF_Attribute)& into,
     if (!RT->HasRelocation(myChildren(i), func) && RT->AfterRelocate()) {
       func.Nullify();
     }
-    intof->SetChild(func);
+    if (!func.IsNull()) {
+      intof->SetChild(func);
+    }
   }
   intof->SetGraphID(myGraphID);
 }