Don't crash when OCC fails to read a model and didn't open the doc.
This commit is contained in:
parent
26c8c718eb
commit
9345b73af5
|
@ -209,6 +209,7 @@ STEP_PCB_MODEL::STEP_PCB_MODEL( const wxString& aPcbName )
|
|||
|
||||
STEP_PCB_MODEL::~STEP_PCB_MODEL()
|
||||
{
|
||||
if( m_doc->CanClose() == CDM_CCS_OK )
|
||||
m_doc->Close();
|
||||
}
|
||||
|
||||
|
@ -1467,14 +1468,18 @@ bool STEP_PCB_MODEL::readIGES( Handle( TDocStd_Document )& doc, const char* fnam
|
|||
|
||||
if( !reader.Transfer( doc ) )
|
||||
{
|
||||
if( doc->CanClose() == CDM_CCS_OK )
|
||||
doc->Close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// are there any shapes to translate?
|
||||
if( reader.NbShapes() < 1 )
|
||||
{
|
||||
if( doc->CanClose() == CDM_CCS_OK )
|
||||
doc->Close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1505,14 +1510,18 @@ bool STEP_PCB_MODEL::readSTEP( Handle( TDocStd_Document )& doc, const char* fnam
|
|||
|
||||
if( !reader.Transfer( doc ) )
|
||||
{
|
||||
if( doc->CanClose() == CDM_CCS_OK )
|
||||
doc->Close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// are there any shapes to translate?
|
||||
if( reader.NbRootsForTransfer() < 1 )
|
||||
{
|
||||
if( doc->CanClose() == CDM_CCS_OK )
|
||||
doc->Close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -554,11 +554,21 @@ bool readIGES( Handle( TDocStd_Document ) & m_doc, const char* fname )
|
|||
reader.SetLayerMode(false); // ignore LAYER data
|
||||
|
||||
if( !reader.Transfer( m_doc ) )
|
||||
{
|
||||
if( m_doc->CanClose() == CDM_CCS_OK )
|
||||
m_doc->Close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// are there any shapes to translate?
|
||||
if( reader.NbShapes() < 1 )
|
||||
{
|
||||
if( m_doc->CanClose() == CDM_CCS_OK )
|
||||
m_doc->Close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -589,13 +599,20 @@ bool readSTEP( Handle(TDocStd_Document)& m_doc, const char* fname )
|
|||
|
||||
if( !reader.Transfer( m_doc ) )
|
||||
{
|
||||
if( m_doc->CanClose() == CDM_CCS_OK )
|
||||
m_doc->Close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// are there any shapes to translate?
|
||||
if( reader.NbRootsForTransfer() < 1 )
|
||||
{
|
||||
if( m_doc->CanClose() == CDM_CCS_OK )
|
||||
m_doc->Close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -685,34 +702,27 @@ SCENEGRAPH* LoadModel( char const* filename )
|
|||
data.renderBoth = true;
|
||||
|
||||
if( !readIGES( data.m_doc, filename ) )
|
||||
{
|
||||
m_app->Close( data.m_doc );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FMT_STEP:
|
||||
if( !readSTEP( data.m_doc, filename ) )
|
||||
{
|
||||
m_app->Close( data.m_doc );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FMT_STPZ:
|
||||
if( !readSTEPZ( data.m_doc, filename ) )
|
||||
{
|
||||
m_app->Close( data.m_doc );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
if( m_app->CanClose( data.m_doc ) == CDM_CCS_OK )
|
||||
m_app->Close( data.m_doc );
|
||||
|
||||
return nullptr;
|
||||
break;
|
||||
}
|
||||
|
@ -749,7 +759,9 @@ SCENEGRAPH* LoadModel( char const* filename )
|
|||
|
||||
if( !ret )
|
||||
{
|
||||
if( m_app->CanClose( data.m_doc ) == CDM_CCS_OK )
|
||||
m_app->Close( data.m_doc );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -776,7 +788,9 @@ SCENEGRAPH* LoadModel( char const* filename )
|
|||
// set to NULL to prevent automatic destruction of the scene data
|
||||
data.scene = nullptr;
|
||||
|
||||
if( m_app->CanClose( data.m_doc ) == CDM_CCS_OK )
|
||||
m_app->Close( data.m_doc );
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue