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()
|
STEP_PCB_MODEL::~STEP_PCB_MODEL()
|
||||||
{
|
{
|
||||||
|
if( m_doc->CanClose() == CDM_CCS_OK )
|
||||||
m_doc->Close();
|
m_doc->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1467,14 +1468,18 @@ bool STEP_PCB_MODEL::readIGES( Handle( TDocStd_Document )& doc, const char* fnam
|
||||||
|
|
||||||
if( !reader.Transfer( doc ) )
|
if( !reader.Transfer( doc ) )
|
||||||
{
|
{
|
||||||
|
if( doc->CanClose() == CDM_CCS_OK )
|
||||||
doc->Close();
|
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( doc->CanClose() == CDM_CCS_OK )
|
||||||
doc->Close();
|
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 ) )
|
||||||
{
|
{
|
||||||
|
if( doc->CanClose() == CDM_CCS_OK )
|
||||||
doc->Close();
|
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( doc->CanClose() == CDM_CCS_OK )
|
||||||
doc->Close();
|
doc->Close();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -554,11 +554,21 @@ bool readIGES( Handle( TDocStd_Document ) & m_doc, const char* fname )
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -589,13 +599,20 @@ bool readSTEP( Handle(TDocStd_Document)& m_doc, const char* fname )
|
||||||
|
|
||||||
if( !reader.Transfer( m_doc ) )
|
if( !reader.Transfer( m_doc ) )
|
||||||
{
|
{
|
||||||
|
if( m_doc->CanClose() == CDM_CCS_OK )
|
||||||
m_doc->Close();
|
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:
|
||||||
|
if( m_app->CanClose( data.m_doc ) == CDM_CCS_OK )
|
||||||
m_app->Close( data.m_doc );
|
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 )
|
||||||
{
|
{
|
||||||
|
if( m_app->CanClose( data.m_doc ) == CDM_CCS_OK )
|
||||||
m_app->Close( data.m_doc );
|
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;
|
||||||
|
|
||||||
|
if( m_app->CanClose( data.m_doc ) == CDM_CCS_OK )
|
||||||
m_app->Close( data.m_doc );
|
m_app->Close( data.m_doc );
|
||||||
|
|
||||||
return scene;
|
return scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue