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,7 +209,8 @@ STEP_PCB_MODEL::STEP_PCB_MODEL( const wxString& aPcbName )
|
||||||
|
|
||||||
STEP_PCB_MODEL::~STEP_PCB_MODEL()
|
STEP_PCB_MODEL::~STEP_PCB_MODEL()
|
||||||
{
|
{
|
||||||
m_doc->Close();
|
if( m_doc->CanClose() == CDM_CCS_OK )
|
||||||
|
m_doc->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool STEP_PCB_MODEL::AddPadShape( const PAD* aPad, const VECTOR2D& aOrigin )
|
bool STEP_PCB_MODEL::AddPadShape( const PAD* aPad, const VECTOR2D& aOrigin )
|
||||||
|
@ -1467,14 +1468,18 @@ bool STEP_PCB_MODEL::readIGES( Handle( TDocStd_Document )& doc, const char* fnam
|
||||||
|
|
||||||
if( !reader.Transfer( doc ) )
|
if( !reader.Transfer( doc ) )
|
||||||
{
|
{
|
||||||
doc->Close();
|
if( doc->CanClose() == CDM_CCS_OK )
|
||||||
|
doc->Close();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// are there any shapes to translate?
|
// are there any shapes to translate?
|
||||||
if( reader.NbShapes() < 1 )
|
if( reader.NbShapes() < 1 )
|
||||||
{
|
{
|
||||||
doc->Close();
|
if( doc->CanClose() == CDM_CCS_OK )
|
||||||
|
doc->Close();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1505,14 +1510,18 @@ bool STEP_PCB_MODEL::readSTEP( Handle( TDocStd_Document )& doc, const char* fnam
|
||||||
|
|
||||||
if( !reader.Transfer( doc ) )
|
if( !reader.Transfer( doc ) )
|
||||||
{
|
{
|
||||||
doc->Close();
|
if( doc->CanClose() == CDM_CCS_OK )
|
||||||
|
doc->Close();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// are there any shapes to translate?
|
// are there any shapes to translate?
|
||||||
if( reader.NbRootsForTransfer() < 1 )
|
if( reader.NbRootsForTransfer() < 1 )
|
||||||
{
|
{
|
||||||
doc->Close();
|
if( doc->CanClose() == CDM_CCS_OK )
|
||||||
|
doc->Close();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -553,12 +553,22 @@ bool readIGES( Handle( TDocStd_Document ) & m_doc, const char* fname )
|
||||||
reader.SetNameMode(false); // don't use IGES label names
|
reader.SetNameMode(false); // don't use IGES label names
|
||||||
reader.SetLayerMode(false); // ignore LAYER data
|
reader.SetLayerMode(false); // ignore LAYER data
|
||||||
|
|
||||||
if ( !reader.Transfer( m_doc ) )
|
if( !reader.Transfer( m_doc ) )
|
||||||
|
{
|
||||||
|
if( m_doc->CanClose() == CDM_CCS_OK )
|
||||||
|
m_doc->Close();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// are there any shapes to translate?
|
// are there any shapes to translate?
|
||||||
if( reader.NbShapes() < 1 )
|
if( reader.NbShapes() < 1 )
|
||||||
|
{
|
||||||
|
if( m_doc->CanClose() == CDM_CCS_OK )
|
||||||
|
m_doc->Close();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -587,15 +597,22 @@ bool readSTEP( Handle(TDocStd_Document)& m_doc, const char* fname )
|
||||||
reader.SetNameMode( false ); // don't use label names
|
reader.SetNameMode( false ); // don't use label names
|
||||||
reader.SetLayerMode( false ); // ignore LAYER data
|
reader.SetLayerMode( false ); // ignore LAYER data
|
||||||
|
|
||||||
if ( !reader.Transfer( m_doc ) )
|
if( !reader.Transfer( m_doc ) )
|
||||||
{
|
{
|
||||||
m_doc->Close();
|
if( m_doc->CanClose() == CDM_CCS_OK )
|
||||||
|
m_doc->Close();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// are there any shapes to translate?
|
// are there any shapes to translate?
|
||||||
if( reader.NbRootsForTransfer() < 1 )
|
if( reader.NbRootsForTransfer() < 1 )
|
||||||
|
{
|
||||||
|
if( m_doc->CanClose() == CDM_CCS_OK )
|
||||||
|
m_doc->Close();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -685,34 +702,27 @@ SCENEGRAPH* LoadModel( char const* filename )
|
||||||
data.renderBoth = true;
|
data.renderBoth = true;
|
||||||
|
|
||||||
if( !readIGES( data.m_doc, filename ) )
|
if( !readIGES( data.m_doc, filename ) )
|
||||||
{
|
|
||||||
m_app->Close( data.m_doc );
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FMT_STEP:
|
case FMT_STEP:
|
||||||
if( !readSTEP( data.m_doc, filename ) )
|
if( !readSTEP( data.m_doc, filename ) )
|
||||||
{
|
|
||||||
m_app->Close( data.m_doc );
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FMT_STPZ:
|
case FMT_STPZ:
|
||||||
if( !readSTEPZ( data.m_doc, filename ) )
|
if( !readSTEPZ( data.m_doc, filename ) )
|
||||||
{
|
|
||||||
m_app->Close( data.m_doc );
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
m_app->Close( data.m_doc );
|
if( m_app->CanClose( data.m_doc ) == CDM_CCS_OK )
|
||||||
|
m_app->Close( data.m_doc );
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -749,7 +759,9 @@ SCENEGRAPH* LoadModel( char const* filename )
|
||||||
|
|
||||||
if( !ret )
|
if( !ret )
|
||||||
{
|
{
|
||||||
m_app->Close( data.m_doc );
|
if( m_app->CanClose( data.m_doc ) == CDM_CCS_OK )
|
||||||
|
m_app->Close( data.m_doc );
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,7 +788,9 @@ SCENEGRAPH* LoadModel( char const* filename )
|
||||||
// set to NULL to prevent automatic destruction of the scene data
|
// set to NULL to prevent automatic destruction of the scene data
|
||||||
data.scene = nullptr;
|
data.scene = nullptr;
|
||||||
|
|
||||||
m_app->Close( data.m_doc );
|
if( m_app->CanClose( data.m_doc ) == CDM_CCS_OK )
|
||||||
|
m_app->Close( data.m_doc );
|
||||||
|
|
||||||
return scene;
|
return scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue