#include "wx/ptr_scpd.h"
#include "wx/module.h"
+#include "wx/except.h"
#if defined(__WXMSW__) && defined(__WXDEBUG__)
#include "wx/msw/msvcrt.h"
gs_initData.argv[i] = wxStrdup(wxConvLocal.cMB2WX(argv[i]));
}
+ gs_initData.argc = argc;
gs_initData.argv[argc] = NULL;
}
delete [] gs_initData.argv;
gs_initData.argv = NULL;
+ gs_initData.argc = 0;
}
}
// clean up
// ----------------------------------------------------------------------------
-// cleanup done before destroying wxTheApp
+// cleanup done before destroying wxTheApp
static void DoCommonPreCleanup()
{
#if wxUSE_LOG
// flush the logged messages if any and install a 'safer' log target: the
// default one (wxLogGui) can't be used after the resources are freed just
// below and the user supplied one might be even more unsafe (using any
- // wxWindows GUI function is unsafe starting from now)
+ // wxWidgets GUI function is unsafe starting from now)
wxLog::DontCreateOnDemand();
// this will flush the old messages if any
delete wxLog::SetActiveTarget(new wxLogStderr);
#endif // wxUSE_LOG
-
- wxModule::CleanUpModules();
}
// cleanup done after destroying wxTheApp
static void DoCommonPostCleanup()
{
+ wxModule::CleanUpModules();
+
wxClassInfo::CleanUp();
// we can't do this in wxApp itself because it doesn't know if argv had
FreeConvertedArgs();
#endif // wxUSE_UNICODE
- // check for memory leaks
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
- {
- wxLogDebug(wxT("There were memory leaks.\n"));
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
-#endif // Debug
-
+ // Note: check for memory leaks is now done via wxDebugContextDumpDelayCounter
#if wxUSE_LOG
// and now delete the last logger as well
delete wxLog::SetActiveTarget(NULL);
WX_SUPPRESS_UNUSED_WARN(cleanupOnExit);
- // app initialization
- if ( !wxTheApp->CallOnInit() )
+ wxTRY
{
- // don't call OnExit() if OnInit() failed
- return -1;
- }
- // app execution
- int retValue = wxTheApp->OnRun();
+ // app initialization
+ if ( !wxTheApp->CallOnInit() )
+ {
+ // don't call OnExit() if OnInit() failed
+ return -1;
+ }
- // app clean up
- wxTheApp->OnExit();
+ // ensure that OnExit() is called if OnInit() had succeeded
+ class CallOnExit
+ {
+ public:
+ ~CallOnExit() { wxTheApp->OnExit(); }
+ } callOnExit;
- return retValue;
+ WX_SUPPRESS_UNUSED_WARN(callOnExit);
+
+ // app execution
+ return wxTheApp->OnRun();
+ }
+ wxCATCH_ALL( wxTheApp->OnUnhandledException(); return -1; )
}
// wrap real wxEntry in a try-except block to be able to call
{
#ifdef __WXWINCE__
::ExitThread(3); // the same exit code as abort()
+#elif __WXPALMOS__
+ return -1;
#else
::ExitProcess(3); // the same exit code as abort()
#endif