+
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+static bool DoInit()
+{
+ wxClassInfo::InitializeClasses();
+
+ wxModule::RegisterModules();
+ if ( !wxModule::InitializeModules() )
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void DoCleanUp()
+{
+#if wxUSE_LOG
+ // flush the logged messages if any
+ wxLog *log = wxLog::GetActiveTarget();
+ if (log != NULL && log->HasPendingMessages())
+ log->Flush();
+
+ // continuing to use user defined log target is unsafe from now on because
+ // some resources may be already unavailable, so replace it by something
+ // more safe
+ wxLog::DontCreateOnDemand();
+ delete wxLog::SetActiveTarget(new wxLogStderr);
+#endif // wxUSE_LOG
+
+ wxModule::CleanUpModules();
+
+ wxClassInfo::CleanUpClasses();
+
+ // TODO: this should really be done in ~wxApp
+#if wxUSE_UNICODE
+ for ( int mb_argc = 0; mb_argc < wxTheApp->argc; mb_argc++ )
+ {
+ free(wxTheApp->argv[mb_argc]);
+ }
+#endif // wxUSE_UNICODE
+
+ // delete the application object
+ delete wxTheApp;
+ wxTheApp = (wxApp *)NULL;
+
+#if wxUSE_LOG
+ // and now delete the last logger as well
+ delete wxLog::SetActiveTarget(NULL);
+#endif // wxUSE_LOG
+}
+