Fix compilation errors when wxUSE_ON_FATAL_EXCEPTION is not enabled. Updates #1423.

Originally committed to SVN as r6359.
This commit is contained in:
Thomas Goyne 2012-01-25 19:07:07 +00:00
parent d798d69849
commit e9dcbf66f3
2 changed files with 3 additions and 9 deletions

View file

@ -217,7 +217,7 @@ bool AegisubApp::OnInit() {
setlocale(LC_CTYPE, "C"); setlocale(LC_CTYPE, "C");
// Crash handling // Crash handling
#if !defined(_DEBUG) || defined(WITH_EXCEPTIONS) #if (!defined(_DEBUG) || defined(WITH_EXCEPTIONS)) && (wxUSE_ON_FATAL_EXCEPTION+0)
StartupLog("Install exception handler"); StartupLog("Install exception handler");
wxHandleFatalExceptions(true); wxHandleFatalExceptions(true);
#endif #endif
@ -312,12 +312,11 @@ int AegisubApp::OnExit() {
return wxApp::OnExit(); return wxApp::OnExit();
} }
#if !defined(_DEBUG) || defined(WITH_EXCEPTIONS)
/// Message displayed when an exception has occurred. /// Message displayed when an exception has occurred.
const static wxString exception_message = _("Oops, Aegisub has crashed!\n\nAn attempt has been made to save a copy of your file to:\n\n%s\n\nAegisub will now close."); const static wxString exception_message = _("Oops, Aegisub has crashed!\n\nAn attempt has been made to save a copy of your file to:\n\n%s\n\nAegisub will now close.");
static void UnhandledExeception(bool stackWalk) { static void UnhandledExeception(bool stackWalk) {
#if (!defined(_DEBUG) || defined(WITH_EXCEPTIONS)) && (wxUSE_ON_FATAL_EXCEPTION+0)
if (AssFile::top) { if (AssFile::top) {
// Current filename if any. // Current filename if any.
wxFileName file(AssFile::top->filename); wxFileName file(AssFile::top->filename);
@ -350,6 +349,7 @@ static void UnhandledExeception(bool stackWalk) {
#endif #endif
wxMessageBox(wxString::Format("Aegisub has crashed while starting up!\n\nThe last startup step attempted was: %s.", LastStartupState), _("Program error"), wxOK | wxICON_ERROR); wxMessageBox(wxString::Format("Aegisub has crashed while starting up!\n\nThe last startup step attempted was: %s.", LastStartupState), _("Program error"), wxOK | wxICON_ERROR);
} }
#endif
} }
/// @brief Called during an unhandled exception /// @brief Called during an unhandled exception
@ -362,8 +362,6 @@ void AegisubApp::OnUnhandledException() {
void AegisubApp::OnFatalException() { void AegisubApp::OnFatalException() {
UnhandledExeception(true); UnhandledExeception(true);
} }
#endif
void AegisubApp::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const { void AegisubApp::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const {
#define SHOW_EXCEPTION(str) wxMessageBox(str, "Exception in event handler", wxOK|wxICON_ERROR|wxSTAY_ON_TOP) #define SHOW_EXCEPTION(str) wxMessageBox(str, "Exception in event handler", wxOK|wxICON_ERROR|wxSTAY_ON_TOP)
@ -499,9 +497,7 @@ int AegisubApp::OnRun() {
file.close(); file.close();
} }
#if wxUSE_EXCEPTIONS
OnUnhandledException(); OnUnhandledException();
#endif
} }
ExitMainLoop(); ExitMainLoop();

View file

@ -97,10 +97,8 @@ class AegisubApp: public wxApp {
int OnExit(); int OnExit();
int OnRun(); int OnRun();
#if !defined(_DEBUG) || defined(WITH_EXCEPTIONS)
void OnUnhandledException(); void OnUnhandledException();
void OnFatalException(); void OnFatalException();
#endif
/// @brief Handle wx assertions and redirect to the logging system. /// @brief Handle wx assertions and redirect to the logging system.
/// @param file File name /// @param file File name