modview: Re-instate the try/catch block when loading

Setting up the footprint viewer will attempt to load the current
footprint.  If the library does not exist, the loader will throw an
IO_ERROR that needs to be caught.

Fixes: lp:1789626
* https://bugs.launchpad.net/kicad/+bug/1789626
This commit is contained in:
Seth Hillbrand 2018-08-31 08:43:50 -07:00
parent d6b95236a4
commit ee12fe6eff
1 changed files with 22 additions and 8 deletions

View File

@ -634,16 +634,30 @@ bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aResulta
if( aFootprint && !aFootprint->IsEmpty() )
{
LIB_ID fpid;
fpid.Parse( *aFootprint, LIB_ID::ID_PCB, true );
if( fpid.IsValid() )
// Loading the footprint will throw an IO Error on a missing footprint library
try
{
setCurNickname( fpid.GetLibNickname() );
setCurFootprintName( fpid.GetLibItemName() );
ReCreateFootprintList();
SelectAndViewFootprint( NEW_PART );
fpid.Parse( *aFootprint, LIB_ID::ID_PCB, true );
if( fpid.IsValid() )
{
setCurNickname( fpid.GetLibNickname() );
setCurFootprintName( fpid.GetLibItemName() );
ReCreateFootprintList();
SelectAndViewFootprint( NEW_PART );
}
}
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format(
_( "Could not load footprint \"%s\" from library \"%s\".\n\nError %s." ),
GetChars( fpid.GetLibItemName() ),
GetChars( fpid.GetLibNickname() ),
GetChars( ioe.What() ) );
DisplayError( this, msg );
}
catch( ... ) {}
}
return KIWAY_PLAYER::ShowModal( aFootprint, aResultantFocusWindow );