From: snn Date: Tue, 6 Nov 2018 13:19:46 +0000 (+0300) Subject: 0030341: Unset child/parent links bugs fix X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=7ac456d54662d843cdf35ecb179e5e16b87e8dd0;p=occt-copy.git 0030341: Unset child/parent links bugs fix --- diff --git a/src/XCAFDoc/XCAFDoc_GraphNode.cxx b/src/XCAFDoc/XCAFDoc_GraphNode.cxx index 0e904a6c0c..5373293c39 100644 --- a/src/XCAFDoc/XCAFDoc_GraphNode.cxx +++ b/src/XCAFDoc/XCAFDoc_GraphNode.cxx @@ -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); }