mirror of https://github.com/PCSX2/pcsx2.git
wxgui: better fix for universal message-level exception handling.
git-svn-id: http://pcsx2.googlecode.com/svn/branches/wxgui@1728 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
f7a44a7af2
commit
1ebfee30e9
|
@ -544,24 +544,24 @@ Exception::PluginLoadError::PluginLoadError( PluginsEnum_t pid, const wxString&
|
||||||
|
|
||||||
wxString Exception::PluginLoadError::FormatDiagnosticMessage() const
|
wxString Exception::PluginLoadError::FormatDiagnosticMessage() const
|
||||||
{
|
{
|
||||||
return wxsFormat( m_message_diag, tbl_PluginInfo[PluginId].GetShortname() ) +
|
return wxsFormat( m_message_diag, tbl_PluginInfo[PluginId].GetShortname().c_str() ) +
|
||||||
L"\n\n" + StreamName;
|
L"\n\n" + StreamName;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString Exception::PluginLoadError::FormatDisplayMessage() const
|
wxString Exception::PluginLoadError::FormatDisplayMessage() const
|
||||||
{
|
{
|
||||||
return wxsFormat( m_message_user, tbl_PluginInfo[PluginId].GetShortname() ) +
|
return wxsFormat( m_message_user, tbl_PluginInfo[PluginId].GetShortname().c_str() ) +
|
||||||
L"\n\n" + StreamName;
|
L"\n\n" + StreamName;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString Exception::PluginError::FormatDiagnosticMessage() const
|
wxString Exception::PluginError::FormatDiagnosticMessage() const
|
||||||
{
|
{
|
||||||
return wxsFormat( m_message_diag, tbl_PluginInfo[PluginId].GetShortname() );
|
return wxsFormat( m_message_diag, tbl_PluginInfo[PluginId].GetShortname().c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString Exception::PluginError::FormatDisplayMessage() const
|
wxString Exception::PluginError::FormatDisplayMessage() const
|
||||||
{
|
{
|
||||||
return wxsFormat( m_message_user, tbl_PluginInfo[PluginId].GetShortname() );
|
return wxsFormat( m_message_user, tbl_PluginInfo[PluginId].GetShortname().c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -698,14 +698,13 @@ static bool OpenPlugin_CDVD()
|
||||||
|
|
||||||
static bool OpenPlugin_GS()
|
static bool OpenPlugin_GS()
|
||||||
{
|
{
|
||||||
if( !mtgsThread->IsSelf() )
|
if( mtgsThread == NULL )
|
||||||
{
|
{
|
||||||
if( mtgsThread == NULL )
|
mtgsOpen(); // mtgsOpen raises its own exception on error
|
||||||
mtgsOpen(); // mtgsOpen raises its own exception on error
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if( mtgsThread->IsSelf() )
|
||||||
return !GSopen( (void*)&pDsp, "PCSX2", renderswitch ? 2 : 1 );
|
return !GSopen( (void*)&pDsp, "PCSX2", renderswitch ? 2 : 1 );
|
||||||
|
|
||||||
// Note: rederswitch is us abusing the isMultiThread parameter for that so
|
// Note: rederswitch is us abusing the isMultiThread parameter for that so
|
||||||
|
|
|
@ -181,7 +181,7 @@ protected:
|
||||||
void CleanupMess();
|
void CleanupMess();
|
||||||
void OpenWizardConsole();
|
void OpenWizardConsole();
|
||||||
|
|
||||||
int MainLoop();
|
void HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Override wx default exception handling behavior
|
// Override wx default exception handling behavior
|
||||||
|
|
|
@ -577,7 +577,7 @@ namespace Console
|
||||||
// [TODO] make this a configurable option? Do we care? :)
|
// [TODO] make this a configurable option? Do we care? :)
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
// puts does automatic newlines, which we don't want here
|
// puts does automatic newlines, which we don't want here
|
||||||
fputs( L"PCSX2 > ", stdout );
|
fputs( "PCSX2 > ", stdout );
|
||||||
fputs( src, stdout );
|
fputs( src, stdout );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -307,78 +307,28 @@ void Pcsx2App::CleanupMess()
|
||||||
safe_delete( g_Conf );
|
safe_delete( g_Conf );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pxRunningEventLoopCount = 0;
|
void Pcsx2App::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const
|
||||||
|
|
||||||
class pxEvtLoop : public wxEventLoop
|
|
||||||
{
|
{
|
||||||
protected:
|
try
|
||||||
struct pxRunningEventLoopCounter
|
|
||||||
{
|
{
|
||||||
pxRunningEventLoopCounter() { pxRunningEventLoopCount++; }
|
(handler->*func)(event);
|
||||||
~pxRunningEventLoopCounter() { pxRunningEventLoopCount--; }
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual int Run()
|
|
||||||
{
|
|
||||||
// event loops are not recursive, you need to create another loop!
|
|
||||||
wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") );
|
|
||||||
|
|
||||||
wxEventLoopActivator activate(wx_static_cast(wxEventLoop *, this));
|
|
||||||
|
|
||||||
#if defined(__WXMSW__) && wxUSE_THREADS
|
|
||||||
pxRunningEventLoopCounter evtLoopCounter;
|
|
||||||
#endif // __WXMSW__
|
|
||||||
|
|
||||||
while( true )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
while( !m_shouldExit )
|
|
||||||
{
|
|
||||||
// give ourselves the possibility to do whatever we want!
|
|
||||||
OnNextIteration();
|
|
||||||
|
|
||||||
while( Pending() )
|
|
||||||
{
|
|
||||||
if( !Dispatch() )
|
|
||||||
{
|
|
||||||
m_shouldExit = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( wxTheApp )
|
|
||||||
wxTheApp->ProcessIdle();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
catch( Exception::PluginError& ex )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
catch( Exception::RuntimeError& ex )
|
|
||||||
{
|
|
||||||
// Runtime errors which have been unhandled should still be safe to recover from,
|
|
||||||
// so lets issue a message to the user and then continue the message pump.
|
|
||||||
|
|
||||||
Console::Error( ex.FormatDiagnosticMessage() );
|
|
||||||
Msgbox::Alert( ex.FormatDisplayMessage() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
// ----------------------------------------------------------------------------
|
||||||
|
catch( Exception::PluginError& ex )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
catch( Exception::RuntimeError& ex )
|
||||||
|
{
|
||||||
|
// Runtime errors which have been unhandled should still be safe to recover from,
|
||||||
|
// so lets issue a message to the user and then continue the message pump.
|
||||||
|
|
||||||
// This overload performs universal exception handling for specific types of recoverable
|
Console::Error( ex.FormatDiagnosticMessage() );
|
||||||
// errors that can be thrown from a multitude of events.
|
Msgbox::Alert( ex.FormatDisplayMessage() );
|
||||||
int Pcsx2App::MainLoop()
|
}
|
||||||
{
|
|
||||||
assert( m_mainLoop == NULL );
|
|
||||||
m_mainLoop = new pxEvtLoop();
|
|
||||||
return m_mainLoop->Run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Common exit handler which can be called from any event (though really it should
|
// Common exit handler which can be called from any event (though really it should
|
||||||
// be called only from CloseWindow handlers since that's the more appropriate way
|
// be called only from CloseWindow handlers since that's the more appropriate way
|
||||||
// to handle window closures)
|
// to handle window closures)
|
||||||
|
|
Loading…
Reference in New Issue