X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fb3e83b60a5eeb499bb2934ce4fa0f0cdff5fbec..a2d452d042ef1e2a6a17dcbc271183b947669bb3:/src/common/init.cpp diff --git a/src/common/init.cpp b/src/common/init.cpp index 774cbd2273..a67f723b64 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -396,6 +396,7 @@ int wxEntryReal(int& argc, wxChar **argv) wxTRY { + // app initialization if ( !wxTheApp->CallOnInit() ) { @@ -403,13 +404,17 @@ int wxEntryReal(int& argc, wxChar **argv) return -1; } - // app execution - int retValue = wxTheApp->OnRun(); + // ensure that OnExit() is called if OnInit() had succeeded + class CallOnExit + { + public: + ~CallOnExit() { wxTheApp->OnExit(); } + } callOnExit; - // app clean up - wxTheApp->OnExit(); + WX_SUPPRESS_UNUSED_WARN(callOnExit); - return retValue; + // app execution + return wxTheApp->OnRun(); } wxCATCH_ALL( wxTheApp->OnUnhandledException(); return -1; ) }