Don't hard crash on a failed kiway player due to null reference

This is possible if a kiface fails loading due to missing dlls, etc
This commit is contained in:
Marek Roszko 2020-11-13 21:14:03 -05:00
parent ec020dd19f
commit 5100f720ef
2 changed files with 10 additions and 5 deletions

View File

@ -351,7 +351,7 @@ KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate, wxTopLevelWindow
// way it gets some explanatory text. // way it gets some explanatory text.
wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFrameType" ) ); wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFrameType" ) );
return NULL; return nullptr;
} }
// return the previously opened window // return the previously opened window
@ -381,19 +381,19 @@ KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate, wxTopLevelWindow
} }
catch( const IO_ERROR& ioe ) catch( const IO_ERROR& ioe )
{ {
DisplayErrorMessage( NULL, _( "Error loading editor" ), ioe.What() ); DisplayErrorMessage( nullptr, _( "Error loading editor" ), ioe.What() );
} }
catch( const std::exception& e) catch( const std::exception& e)
{ {
DisplayErrorMessage( NULL, _( "Error loading editor" ), e.what() ); DisplayErrorMessage( nullptr, _( "Error loading editor" ), e.what() );
} }
catch( ... ) catch( ... )
{ {
DisplayErrorMessage( NULL, _( "Error loading editor" ) ); DisplayErrorMessage( nullptr, _( "Error loading editor" ) );
} }
} }
return NULL; return nullptr;
} }

View File

@ -369,6 +369,11 @@ bool PGM_SINGLE_TOP::OnPgmInit()
// and is one of the types in FRAME_T. // and is one of the types in FRAME_T.
KIWAY_PLAYER* frame = Kiway.Player( appType, true ); KIWAY_PLAYER* frame = Kiway.Player( appType, true );
if( frame == nullptr )
{
return false;
}
Kiway.SetTop( frame ); Kiway.SetTop( frame );
App().SetTopWindow( frame ); // wxApp gets a face. App().SetTopWindow( frame ); // wxApp gets a face.