A check on NULL is added to prevent the crash.
Adding test case for this fix
// TDF_Tool::Entry(att->Label(), entr1);
// cout<<"\t\tReferences attribute dynamic type = "<<att->DynamicType()<<" Label = "<<entr1 <<endl;
- if (aFilter.IsKept(att) && att->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);
// 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();
}
--- /dev/null
+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"
+}
puts "TODO ?#22623 ALL: \\*\\* Exception"
puts "TODO ?#22623 ALL: An exception was caught"
+puts "TODO ?#22623 ALL: TEST INCOMPLETE"
puts "============"
puts "OCC22623"