Commit b427aa49 authored by Dick Hollenbeck's avatar Dick Hollenbeck

single_top w/o kiface whines and exits gracefully.

parent 1e68c5f8
...@@ -107,7 +107,10 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, ...@@ -107,7 +107,10 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event ) void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
{ {
SaveSettings( config() ); // virtual, wxFrame specific wxConfigBase* cfg = config();
if( cfg )
SaveSettings( cfg ); // virtual, wxFrame specific
event.Skip(); // we did not "handle" the event, only eavesdropped on it. event.Skip(); // we did not "handle" the event, only eavesdropped on it.
} }
...@@ -266,7 +269,7 @@ wxConfigBase* EDA_BASE_FRAME::config() ...@@ -266,7 +269,7 @@ wxConfigBase* EDA_BASE_FRAME::config()
{ {
// KICAD_MANAGER_FRAME overrides this // KICAD_MANAGER_FRAME overrides this
wxConfigBase* ret = Kiface().KifaceSettings(); wxConfigBase* ret = Kiface().KifaceSettings();
wxASSERT( ret ); //wxASSERT( ret );
return ret; return ret;
} }
......
...@@ -153,20 +153,42 @@ struct APP_SINGLE_TOP : public wxApp ...@@ -153,20 +153,42 @@ struct APP_SINGLE_TOP : public wxApp
{ {
bool OnInit() // overload wxApp virtual bool OnInit() // overload wxApp virtual
{ {
return Pgm().OnPgmInit( this ); try
{
return Pgm().OnPgmInit( this );
}
catch( const std::exception& e )
{
wxLogError( wxT( "Unhandled exception class: %s what: %s" ),
GetChars( FROM_UTF8( typeid(e).name() )),
GetChars( FROM_UTF8( e.what() ) ) );;
}
catch( const IO_ERROR& ioe )
{
wxLogError( GetChars( ioe.errorText ) );
}
catch(...)
{
wxLogError( wxT( "Unhandled exception of unknown type" ) );
}
Pgm().OnPgmExit();
return false;
} }
int OnExit() // overload wxApp virtual int OnExit() // overload wxApp virtual
{ {
Pgm().OnPgmExit();
return wxApp::OnExit(); return wxApp::OnExit();
} }
int OnRun() // overload wxApp virtual int OnRun() // overload wxApp virtual
{ {
int ret = -1;
try try
{ {
return wxApp::OnRun(); ret = wxApp::OnRun();
} }
catch( const std::exception& e ) catch( const std::exception& e )
{ {
...@@ -183,7 +205,9 @@ struct APP_SINGLE_TOP : public wxApp ...@@ -183,7 +205,9 @@ struct APP_SINGLE_TOP : public wxApp
wxLogError( wxT( "Unhandled exception of unknown type" ) ); wxLogError( wxT( "Unhandled exception of unknown type" ) );
} }
return -1; Pgm().OnPgmExit();
return ret;
} }
/** /**
...@@ -240,10 +264,30 @@ static KIFACE_GETTER_FUNC* get_kiface_getter( const wxString& aDSOName ) ...@@ -240,10 +264,30 @@ static KIFACE_GETTER_FUNC* get_kiface_getter( const wxString& aDSOName )
// No further reporting required here. // No further reporting required here.
} }
// Tell dso's wxDynamicLibrary destructor not to Unload() the program image. else
(void) dso.Detach(); {
// Tell dso's wxDynamicLibrary destructor not to Unload() the program image.
(void) dso.Detach();
return (KIFACE_GETTER_FUNC*) addr;
}
// There is a file installation bug. We only look for KIFACE_I's which we know
// to exist, and we did not find one. If we do not find one, this is an
// installation bug.
wxString msg = wxString::Format( wxT(
"Fatal Installation Bug\nmissing file:\n'%s'\n\nargv[0]:\n'%s'" ),
GetChars( aDSOName ),
GetChars( wxStandardPaths::Get().GetExecutablePath() )
);
return (KIFACE_GETTER_FUNC*) addr; // This is a fatal error, one from which we cannot recover, nor do we want
// to protect against in client code which would require numerous noisy
// tests in numerous places. So we inform the user that the installation
// is bad. This exception will likely not get caught until way up in the
// wxApp derivative, at which point the process will exit gracefully.
THROW_IO_ERROR( msg );
#else #else
return &KIFACE_GETTER; return &KIFACE_GETTER;
...@@ -415,9 +459,8 @@ void PGM_SINGLE_TOP::OnPgmExit() ...@@ -415,9 +459,8 @@ void PGM_SINGLE_TOP::OnPgmExit()
saveCommonSettings(); saveCommonSettings();
// write common settings to disk, and destroy everything in PGM_BASE, // Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl
// especially wxSingleInstanceCheckerImpl earlier than wxApp and earlier // earlier than wxApp and earlier than static destruction would.
// than static destruction would.
PGM_BASE::destroy(); PGM_BASE::destroy();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment