X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7f555861b7e50f335c7b929bb76be38e9ebd69c5..d3acd3697ad19e0edbff62db7f94bd025cf8883b:/src/stubs/app.cpp diff --git a/src/stubs/app.cpp b/src/stubs/app.cpp index 67271c4c3b..681e661556 100644 --- a/src/stubs/app.cpp +++ b/src/stubs/app.cpp @@ -29,14 +29,10 @@ #include "wx/module.h" #include "wx/memory.h" -#if USE_WX_RESOURCES +#if wxUSE_WX_RESOURCES #include "wx/resource.h" #endif -#if USE_POSTSCRIPT -#include "wx/postscrp.h" -#endif - #include extern char *wxBuffer; @@ -44,16 +40,14 @@ extern wxList wxPendingDelete; wxApp *wxTheApp = NULL; -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) EVT_IDLE(wxApp::OnIdle) END_EVENT_TABLE() -#endif long wxApp::sm_lastMessageTime = 0; -void wxApp::CommonInit() +bool wxApp::Initialize() { #ifdef __WXMSW__ wxBuffer = new char[1500]; @@ -61,34 +55,40 @@ 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 @@ -111,12 +111,6 @@ void wxApp::CommonCleanUp() delete wxTheColourDatabase; wxTheColourDatabase = NULL; -#if USE_POSTSCRIPT - wxInitializePrintSetupData(FALSE); - delete wxThePrintPaperDatabase; - wxThePrintPaperDatabase = NULL; -#endif - wxBitmap::CleanUpHandlers(); delete[] wxBuffer; @@ -124,6 +118,23 @@ void wxApp::CommonCleanUp() 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 @@ -132,20 +143,8 @@ void wxApp::CommonCleanUp() 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()) @@ -166,10 +165,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(); @@ -193,25 +188,8 @@ int wxEntry( int argc, char *argv[] ) wxTheApp->OnExit(); - wxApp::CommonCleanUp(); + wxApp::CleanUp(); - delete wxTheApp; - wxTheApp = NULL; - -#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 - return retValue; }; @@ -346,7 +324,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(); @@ -393,7 +371,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.