diff --git a/src/TDF/TDF_CopyLabel.cxx b/src/TDF/TDF_CopyLabel.cxx index 745e7e1905..824f788bfa 100755 --- a/src/TDF/TDF_CopyLabel.cxx +++ b/src/TDF/TDF_CopyLabel.cxx @@ -97,13 +97,16 @@ void TDF_CopyLabel::ExternalReferences(const TDF_Label& aRefLabel, const TDF_Lab // TDF_Tool::Entry(att->Label(), entr1); // cout<<"\t\tReferences attribute dynamic type = "<DynamicType()<<" Label = "<Label().IsDifferent(aRefLabel) && - !att->Label().IsDescendant(aRefLabel)) { - aExternals.Add(att); - extRefFound = Standard_True; + if (!att.IsNull() && !att->Label().IsNull()) + { + if (aFilter.IsKept(att) && att->Label().IsDifferent(aRefLabel) && + !att->Label().IsDescendant(aRefLabel)) { + aExternals.Add(att); + extRefFound = Standard_True; + } } } - + // const TDF_LabelMap& labMap = ds->Labels(); // for (TDF_MapIteratorOfLabelMap labMItr(labMap);labMItr.More(); labMItr.Next()) { // TDF_Tool::Entry(labMItr.Key(), entr1); diff --git a/src/TDF/TDF_Tool.cxx b/src/TDF/TDF_Tool.cxx index bc78cd5c12..740d563a88 100755 --- a/src/TDF/TDF_Tool.cxx +++ b/src/TDF/TDF_Tool.cxx @@ -181,9 +181,12 @@ static Standard_Boolean TDF_Tool_DescendantRef // CLE // const Handle(TDF_Attribute)& att = attMItr.Key(); Handle(TDF_Attribute) att = attMItr.Key(); - // ENDCLE - if (aFilter.IsKept(att) && !att->Label().IsDescendant(aRefLabel)) - return Standard_False; + if (!att.IsNull() && !att->Label().IsNull()) + { + // ENDCLE + if (aFilter.IsKept(att) && !att->Label().IsDescendant(aRefLabel)) + return Standard_False; + } } ds->Clear(); } diff --git a/tests/bugs/caf/bug23799 b/tests/bugs/caf/bug23799 new file mode 100755 index 0000000000..4da857ea6d --- /dev/null +++ b/tests/bugs/caf/bug23799 @@ -0,0 +1,25 @@ +puts "============" +puts "OCC23799" +puts "============" +puts "" +####################################################################### +# Crash on copying a label +####################################################################### + +set BugNumber OCC23799 + +# Create a new document +NewDocument D + +psphere s 100 +explode s f + +ImportShape D 0:1 s +SelectShape D 0:2 s_1 s +ForgetAll D 0:1 + +if { [catch [CopyLabel D 0:2 0:3] ] != 0 } { + puts "${BugNumber}: Error copy label" +} else { + puts "${BugNumber}: OK" +} diff --git a/tests/bugs/moddata_1/bug22623 b/tests/bugs/moddata_1/bug22623 index f75dcca1ef..0c28310dc5 100755 --- a/tests/bugs/moddata_1/bug22623 +++ b/tests/bugs/moddata_1/bug22623 @@ -1,5 +1,6 @@ puts "TODO ?#22623 ALL: \\*\\* Exception" puts "TODO ?#22623 ALL: An exception was caught" +puts "TODO ?#22623 ALL: TEST INCOMPLETE" puts "============" puts "OCC22623"