-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- // At this point we want to check if there are any memory
- // blocks that aren't part of the wxDebugContext itself,
- // as a special case. Then when dumping we need to ignore
- // wxDebugContext, too.
- if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
- {
- wxLogMessage(wxT("There were memory leaks."));
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
- // wxDebugContext::SetStream(NULL, NULL);
-#endif
-
-#if wxUSE_LOG
- // do it as the very last thing because everything else can log messages
- delete wxLog::SetActiveTarget(NULL);
-#endif // wxUSE_LOG
-}
-
-//----------------------------------------------------------------------
-// Entry point helpers, used by wxPython
-//----------------------------------------------------------------------
-
-int WXDLLEXPORT wxEntryStart( int WXUNUSED(argc), char** WXUNUSED(argv) )
-{
- return wxApp::Initialize();
-}
-
-int WXDLLEXPORT wxEntryInitGui()
-{
- wxTheApp->OnInitGui();
- return 0;
-}
-
-void WXDLLEXPORT wxEntryCleanup()
-{
- wxApp::CleanUp();
-}
-
-
-#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
-
-// temporarily disable this warning which would be generated in release builds
-// because of __try
-#ifdef __VISUALC__
- #pragma warning(disable: 4715) // not all control paths return a value
-#endif // Visual C++
-
-//----------------------------------------------------------------------
-// Main wxWindows entry point
-//----------------------------------------------------------------------
-int wxEntry(WXHINSTANCE hInstance,
- WXHINSTANCE WXUNUSED(hPrevInstance),
- char *lpCmdLine,
- int nCmdShow,
- bool enterLoop)
-{
- // do check for memory leaks on program exit
- // (another useful flag is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free
- // deallocated memory which may be used to simulate low-memory condition)
- wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
-#ifdef __MWERKS__
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- // This seems to be necessary since there are 'rogue'
- // objects present at this point (perhaps global objects?)
- // Setting a checkpoint will ignore them as far as the
- // memory checking facility is concerned.
- // Of course you may argue that memory allocated in globals should be
- // checked, but this is a reasonable compromise.
- wxDebugContext::SetCheckpoint();
-#endif
-#endif
-
- // take everything into a try-except block to be able to call
- // OnFatalException() if necessary
-#if wxUSE_ON_FATAL_EXCEPTION
- __try {
-#endif
- wxhInstance = (HINSTANCE) hInstance;
-
- if (!wxEntryStart(0,0))
- return 0;
-
- // create the application object or ensure that one already exists
- if (!wxTheApp)
- {
- // The app may have declared a global application object, but we recommend
- // the IMPLEMENT_APP macro is used instead, which sets an initializer
- // function for delayed, dynamic app object construction.
- wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
- wxT("No initializer - use IMPLEMENT_APP macro.") );
-
- wxTheApp = (*wxApp::GetInitializerFunction()) ();
- }
-
- wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
-
- // save the WinMain() parameters
- wxTheApp->ConvertToStandardCommandArgs(lpCmdLine);
- wxTheApp->m_nCmdShow = nCmdShow;
-
- // GUI-specific initialisation. In fact on Windows we don't have any,
- // but this call is provided for compatibility across platforms.
- wxEntryInitGui();
-
- // We really don't want timestamps by default, because it means
- // we can't simply double-click on the error message and get to that
- // line in the source. So VC++ at least, let's have a sensible default.
-#ifdef __VISUALC__
- wxLog::SetTimestamp(NULL);