Catch exception so that we at least throw up an error message.

Fixes https://gitlab.com/kicad/code/kicad/issues/4677
This commit is contained in:
Jeff Young 2020-07-13 21:21:34 +01:00
parent dd61f6f019
commit 940570e9ec
3 changed files with 22 additions and 25 deletions

View File

@ -116,20 +116,14 @@ static FOOTPRINT_LIST* get_instance_from_id( KIWAY& aKiway, int aId )
{ {
KIFACE* kiface = aKiway.KiFACE( KIWAY::FACE_PCB ); KIFACE* kiface = aKiway.KiFACE( KIWAY::FACE_PCB );
if( !kiface )
return nullptr;
ptr = kiface->IfaceOrAddress( aId ); ptr = kiface->IfaceOrAddress( aId );
if( !ptr ) return static_cast<FOOTPRINT_LIST*>( ptr );
return nullptr;
} }
catch( ... ) catch( ... )
{ {
return nullptr; return nullptr;
} }
return static_cast<FOOTPRINT_LIST*>( ptr );
} }

View File

@ -36,7 +36,7 @@
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#include <wx/debug.h> #include <wx/debug.h>
#include <wx/utils.h> #include <wx/utils.h>
#include <confirm.h>
KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT]; KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT];
int KIWAY::m_kiface_version[KIWAY_FACE_COUNT]; int KIWAY::m_kiface_version[KIWAY_FACE_COUNT];
@ -360,27 +360,31 @@ KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate, wxTopLevelWindow
if( doCreate ) if( doCreate )
{ {
FACE_T face_type = KifaceType( aFrameType ); try
wxASSERT( face_type != FACE_T(-1) );
KIFACE* kiface = KiFACE( face_type );
wxASSERT( kiface );
if( kiface )
{ {
FACE_T face_type = KifaceType( aFrameType );
KIFACE* kiface = KiFACE( face_type );
frame = (KIWAY_PLAYER*) kiface->CreateWindow( frame = (KIWAY_PLAYER*) kiface->CreateWindow(
aParent, // Parent window of frame in modal mode, NULL in non modal mode aParent, // Parent window of frame in modal mode,
aFrameType, // NULL in non modal mode
this, aFrameType,
m_ctl // questionable need, these same flags where passed this,
// to the KIFACE::OnKifaceStart() m_ctl // questionable need, these same flags
); // were passed to KIFACE::OnKifaceStart()
wxASSERT( frame ); );
m_playerFrameName[aFrameType] = frame->GetName(); m_playerFrameName[aFrameType] = frame->GetName();
return frame; return frame;
} }
catch( const IO_ERROR& ioe )
{
DisplayErrorMessage( NULL, _( "Error loading editor" ), ioe.What() );
}
catch( ... )
{
DisplayErrorMessage( NULL, _( "Error loading editor" ) );
}
} }
return NULL; return NULL;

View File

@ -92,7 +92,7 @@ int COMMON_CONTROL::ConfigurePaths( const TOOL_EVENT& aEvent )
// Do nothing here. // Do nothing here.
// A error message is displayed after trying to load _pcbnew.kiface. // A error message is displayed after trying to load _pcbnew.kiface.
} }
} }
else else
{ {
DIALOG_CONFIGURE_PATHS dlg( m_frame, nullptr ); DIALOG_CONFIGURE_PATHS dlg( m_frame, nullptr );
@ -101,7 +101,6 @@ int COMMON_CONTROL::ConfigurePaths( const TOOL_EVENT& aEvent )
m_frame->Kiway().CommonSettingsChanged( true ); m_frame->Kiway().CommonSettingsChanged( true );
} }
return 0; return 0;
} }