X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/93cf77c076b699e8e0b3b0049bd4f80de15997dd..e3e717ecc5add075cd53a04cf24fe27e24170944:/src/stubs/app.cpp diff --git a/src/stubs/app.cpp b/src/stubs/app.cpp index f54a6806e2..b04a01bbe2 100644 --- a/src/stubs/app.cpp +++ b/src/stubs/app.cpp @@ -27,14 +27,14 @@ #include "wx/msgdlg.h" #include "wx/log.h" #include "wx/module.h" +#include "wx/memory.h" -#if USE_WX_RESOURCES +#if wxUSE_WX_RESOURCES #include "wx/resource.h" #endif #include -#if defined(__WIN95__) && !defined(__GNUWIN32__) extern char *wxBuffer; extern wxList wxPendingDelete; @@ -49,7 +49,7 @@ END_EVENT_TABLE() long wxApp::sm_lastMessageTime = 0; -void wxApp::CommonInit() +bool wxApp::Initialize() { #ifdef __WXMSW__ wxBuffer = new char[1500]; @@ -57,40 +57,47 @@ void wxApp::CommonInit() wxBuffer = new char[BUFSIZ + 512]; #endif +/* No longer used +#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT + + streambuf* sBuf = new wxDebugStreamBuf; + ostream* oStr = new ostream(sBuf) ; + wxDebugContext::SetStream(oStr, sBuf); +#endif +*/ + wxClassInfo::InitializeClasses(); wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); wxTheColourDatabase->Initialize(); + + wxInitializeStockLists(); wxInitializeStockObjects(); -#if USE_WX_RESOURCES +#if wxUSE_WX_RESOURCES wxInitializeResourceSystem(); #endif - // For PostScript printing -#if USE_POSTSCRIPT - wxInitializePrintSetupData(); - wxThePrintPaperDatabase = new wxPrintPaperDatabase; - wxThePrintPaperDatabase->CreateDatabase(); -#endif - wxBitmap::InitStandardHandlers(); wxModule::RegisterModules(); wxASSERT( wxModule::InitializeModules() == TRUE ); + + return TRUE; } -void wxApp::CommonCleanUp() +void wxApp::CleanUp() { wxModule::CleanUpModules(); -#if USE_WX_RESOURCES +#if wxUSE_WX_RESOURCES wxCleanUpResourceSystem(); #endif wxDeleteStockObjects() ; // Destroy all GDI lists, etc. + delete wxTheBrushList; wxTheBrushList = NULL; @@ -106,37 +113,40 @@ void wxApp::CommonCleanUp() delete wxTheColourDatabase; wxTheColourDatabase = NULL; -#if USE_POSTSCRIPT - wxInitializePrintSetupData(FALSE); - delete wxThePrintPaperDatabase; - wxThePrintPaperDatabase = NULL; -#endif - wxBitmap::CleanUpHandlers(); delete[] wxBuffer; wxBuffer = NULL; + wxClassInfo::CleanUpClasses(); + + delete wxTheApp; + wxTheApp = NULL; + +#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() > 0) + { + wxTrace("There were memory leaks.\n"); + wxDebugContext::Dump(); + wxDebugContext::PrintStatistics(); + } +// wxDebugContext::SetStream(NULL, NULL); +#endif + + // do it as the very last thing because everything else can log messages + wxLog::DontCreateOnDemand(); // do it as the very last thing because everything else can log messages delete wxLog::SetActiveTarget(NULL); } int wxEntry( int argc, char *argv[] ) { - wxClassInfo::InitializeClasses(); - -#if (WXDEBUG && USE_MEMORY_TRACING) || USE_DEBUG_CONTEXT - -#if !defined(_WINDLL) - streambuf* sBuf = new wxDebugStreamBuf; -#else - streambuf* sBuf = NULL; -#endif - ostream* oStr = new ostream(sBuf) ; - wxDebugContext::SetStream(oStr, sBuf); - -#endif - + if (!wxApp::Initialize()) + return FALSE; if (!wxTheApp) { if (!wxApp::GetInitializerFunction()) @@ -145,7 +155,7 @@ int wxEntry( int argc, char *argv[] ) return 0; }; - wxTheApp = (* wxApp::GetInitializerFunction()) (); + wxTheApp = (wxApp*) (* wxApp::GetInitializerFunction()) (); }; if (!wxTheApp) @@ -157,10 +167,6 @@ int wxEntry( int argc, char *argv[] ) wxTheApp->argc = argc; wxTheApp->argv = argv; - // TODO: your platform-specific initialization. - - wxApp::CommonInit(); - // GUI-specific initialization, such as creating an app context. wxTheApp->OnInitGui(); @@ -170,32 +176,22 @@ int wxEntry( int argc, char *argv[] ) if (!wxTheApp->OnInit()) return 0; - wxTheApp->m_initialized = (wxTopLevelWindows.Number() > 0); - int retValue = 0; if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun(); + + if (wxTheApp->GetTopWindow()) + { + delete wxTheApp->GetTopWindow(); + wxTheApp->SetTopWindow(NULL); + } wxTheApp->DeletePendingObjects(); wxTheApp->OnExit(); - wxApp::CommonCleanUp(); - -#if (WXDEBUG && USE_MEMORY_TRACING) || USE_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() > 0) - { - wxTrace("There were memory leaks.\n"); - wxDebugContext::Dump(); - wxDebugContext::PrintStatistics(); - } - wxDebugContext::SetStream(NULL, NULL); -#endif - + wxApp::CleanUp(); + return retValue; }; @@ -330,7 +326,7 @@ bool wxApp::SendIdleEvents(wxWindow* win) if (event.MoreRequested()) needMore = TRUE; - wxNode* node = win->GetChildren()->First(); + wxNode* node = win->GetChildren().First(); while (node) { wxWindow* win = (wxWindow*) node->Data(); @@ -377,7 +373,7 @@ wxWindow* wxApp::GetTopWindow() const void wxExit() { - wxApp::CommonCleanUp(); + wxApp::CleanUp(); /* * TODO: Exit in some platform-specific way. Not recommended that the app calls this: * only for emergencies.