Use a unique_ptr for ensuring clean up when reading excellon files
This commit is contained in:
parent
6b03b26364
commit
e955f83c51
|
@ -252,19 +252,21 @@ bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName )
|
||||||
if( gerber_layer )
|
if( gerber_layer )
|
||||||
Erase_Current_DrawLayer( false );
|
Erase_Current_DrawLayer( false );
|
||||||
|
|
||||||
EXCELLON_IMAGE* drill_layer = new EXCELLON_IMAGE( layerId );
|
std::unique_ptr<EXCELLON_IMAGE> drill_layer_uptr = std::make_unique<EXCELLON_IMAGE>( layerId );
|
||||||
|
|
||||||
// Read the Excellon drill file:
|
// Read the Excellon drill file:
|
||||||
bool success = drill_layer->LoadFile( aFullFileName );
|
bool success = drill_layer_uptr->LoadFile( aFullFileName );
|
||||||
|
|
||||||
if( !success )
|
if( !success )
|
||||||
{
|
{
|
||||||
delete drill_layer;
|
drill_layer_uptr.reset();
|
||||||
msg.Printf( _( "File %s not found." ), aFullFileName );
|
msg.Printf( _( "File %s not found." ), aFullFileName );
|
||||||
ShowInfoBarError( msg );
|
ShowInfoBarError( msg );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXCELLON_IMAGE* drill_layer = drill_layer_uptr.release();
|
||||||
|
|
||||||
layerId = images->AddGbrImage( drill_layer, layerId );
|
layerId = images->AddGbrImage( drill_layer, layerId );
|
||||||
|
|
||||||
if( layerId < 0 )
|
if( layerId < 0 )
|
||||||
|
|
Loading…
Reference in New Issue