0024280: Documentation of TObj_Model::GetFile() is incorrect
authorkgv <kgv@opencascade.com>
Fri, 25 Oct 2013 05:17:26 +0000 (09:17 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 31 Oct 2013 09:55:44 +0000 (13:55 +0400)
Do not throw exception when model was not stored yet

src/TObj/TObj_Model.cxx

index 998a397..82e194b 100755 (executable)
@@ -224,13 +224,17 @@ Standard_Boolean TObj_Model::Load (const char* theFile)
 
 Handle(TCollection_HAsciiString) TObj_Model::GetFile() const
 {
-  Handle(TDocStd_Document) aDoc = TDocStd_Document::Get(GetLabel());
-  if ( !aDoc.IsNull() ) {
-    TCollection_AsciiString anOldPath( aDoc->GetPath() );
-    if ( !anOldPath.IsEmpty() )
-      return new TCollection_HAsciiString( anOldPath );
+  Handle(TDocStd_Document) aDoc = GetDocument();
+  if ( aDoc.IsNull()
+   || !aDoc->IsStored())
+  {
+    return Handle(TCollection_HAsciiString)();
   }
-  return 0;
+
+  TCollection_AsciiString aPath (aDoc->GetPath());
+  return !aPath.IsEmpty()
+       ? new TCollection_HAsciiString (aPath)
+       : Handle(TCollection_HAsciiString)();
 }
 
 //=======================================================================