0023736: Exeption during reading STEP file in Test Harness
authorika <ika@opencascade.com>
Fri, 8 Feb 2013 10:50:50 +0000 (14:50 +0400)
committerika <ika@opencascade.com>
Fri, 8 Feb 2013 10:50:50 +0000 (14:50 +0400)
Add checking for null name and null id
Adding of test cases for CR23736

src/STEPCAFControl/STEPCAFControl_Reader.cxx
tests/bugs/xde/bug23736 [new file with mode: 0644]

index e3878c6..e1a4e05 100755 (executable)
@@ -1069,8 +1069,9 @@ Standard_Boolean STEPCAFControl_Reader::ReadNames (const Handle(XSControl_WorkSe
         if ( PDR.IsNull() ) continue;
         if ( PDR->HasDescription() && 
             PDR->Description()->Length() >0 ) name = PDR->Description();
-        else if ( PDR->Name()->Length() >0 ) name = PDR->Name();
-        else name = PDR->Id();
+        else if ( !PDR->Name().IsNull() && PDR->Name()->Length() >0 ) name = PDR->Name();
+        else if ( !PDR->Id().IsNull()) name = PDR->Id();
+        else name = new TCollection_HAsciiString;
       }
       // find proper label
       L = FindInstance ( NAUO, STool, Tool, PDFileMap, ShapeLabelMap );
@@ -1086,8 +1087,9 @@ Standard_Boolean STEPCAFControl_Reader::ReadNames (const Handle(XSControl_WorkSe
        Handle(StepBasic_ProductDefinition)::DownCast(enti);
       if(PD.IsNull()) continue;
       Handle(StepBasic_Product) Prod = PD->Formation()->OfProduct();
-      if(Prod->Name()->UsefullLength()>0) name = Prod->Name();
-      else name = Prod->Id();
+      if(!Prod->Name().IsNull() && Prod->Name()->UsefullLength()>0) name = Prod->Name();
+      else if (!Prod->Id().IsNull()) name = Prod->Id();
+      else name = new TCollection_HAsciiString;
       L = GetLabelFromPD ( PD, STool, TP, PDFileMap, ShapeLabelMap );
       if ( L.IsNull() ) continue;
       TCollection_ExtendedString str ( name->String() );
diff --git a/tests/bugs/xde/bug23736 b/tests/bugs/xde/bug23736
new file mode 100644 (file)
index 0000000..c31de25
--- /dev/null
@@ -0,0 +1,15 @@
+puts "============"
+puts "CR23736"
+puts "============"
+puts ""
+######################################################
+# Exeption during reading STEP file in Test Harness
+######################################################
+
+pload DCAF
+
+NewDocument D MDTV-XCAF
+UndoLimit D 100
+NewCommand D
+
+ReadStep D [locate_data_file mat.stp]