mirror of https://github.com/odrling/Aegisub
Add some real exception catching to our wxApp class, now we should be able to get decent messages from all exceptions thrown inside event handlers.
Originally committed to SVN as r4639.
This commit is contained in:
parent
201f654ca9
commit
3589353641
|
@ -340,6 +340,31 @@ void AegisubApp::OnFatalException() {
|
|||
#endif
|
||||
|
||||
|
||||
void AegisubApp::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const {
|
||||
#define SHOW_EXCEPTION(str) wxMessageBox(str, L"Exception in event handler", wxOK|wxICON_ERROR|wxSTAY_ON_TOP)
|
||||
try {
|
||||
wxApp::HandleEvent(handler, func, event);
|
||||
}
|
||||
catch (const agi::Exception &e) {
|
||||
SHOW_EXCEPTION(lagi_wxString(e.GetChainedMessage()));
|
||||
}
|
||||
catch (const std::exception &e) {
|
||||
SHOW_EXCEPTION(wxString(e.what(), wxConvUTF8));
|
||||
}
|
||||
catch (const wchar_t *e) {
|
||||
SHOW_EXCEPTION(wxString(e));
|
||||
}
|
||||
catch (const char *e) {
|
||||
SHOW_EXCEPTION(wxString(e, wxConvUTF8));
|
||||
}
|
||||
catch (const wxString &e) {
|
||||
SHOW_EXCEPTION(e);
|
||||
}
|
||||
#undef SHOW_EXCEPTION
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if wxUSE_STACKWALKER == 1
|
||||
/// @brief Called at the start of walking the stack.
|
||||
/// @param cause cause of the crash.
|
||||
|
|
|
@ -88,8 +88,8 @@ public:
|
|||
|
||||
/// DOCME
|
||||
FrameMain *frame;
|
||||
#ifdef WITH_AUTOMATION
|
||||
|
||||
#ifdef WITH_AUTOMATION
|
||||
/// DOCME
|
||||
Automation4::AutoloadScriptManager *global_scripts;
|
||||
#endif
|
||||
|
@ -115,6 +115,16 @@ public:
|
|||
void OnFatalException();
|
||||
#endif
|
||||
|
||||
#if defined(wxUSE_EXCEPTIONS)
|
||||
// This function wraps all event handler calls anywhere in the application and is
|
||||
// our ticket to catch exeptions happening in event handlers.
|
||||
virtual void HandleEvent(wxEvtHandler *handler,
|
||||
wxEventFunction func,
|
||||
wxEvent& event) const;
|
||||
#else
|
||||
# error wxWidgets is compiled without exceptions support, Aegisub requires exceptions support in wxWidgets to run safely
|
||||
#endif
|
||||
|
||||
//int OnRun();
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
@ -122,11 +132,7 @@ public:
|
|||
DECLARE_APP(AegisubApp)
|
||||
|
||||
|
||||
////////////////
|
||||
// Stack walker
|
||||
#if wxUSE_STACKWALKER == 1
|
||||
|
||||
/// DOCME
|
||||
/// @class StackWalker
|
||||
/// @brief DOCME
|
||||
///
|
||||
|
|
Loading…
Reference in New Issue