From 9482617091b084d4ee006679a450176715d465e0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 30 Jun 2003 18:43:09 +0000 Subject: [PATCH] extracted common initialization/cleanup functions in common/init.cpp; standardized wxEntry() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21518 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/app.h | 115 +++++----- include/wx/apptrait.h | 4 +- include/wx/cocoa/app.h | 5 +- include/wx/gtk/app.h | 7 +- include/wx/gtk1/app.h | 7 +- include/wx/init.h | 83 ++++++++ include/wx/mac/app.h | 5 +- include/wx/mgl/app.h | 6 +- include/wx/motif/app.h | 6 +- include/wx/msw/app.h | 32 +-- include/wx/os2/app.h | 5 +- include/wx/x11/app.h | 4 +- src/cocoa/app.mm | 99 +-------- src/common/appbase.cpp | 30 +++ src/common/appcmn.cpp | 84 +++++++- src/common/fs_mem.cpp | 6 +- src/common/init.cpp | 418 +++++++++++++++++++++++++++--------- src/gtk/app.cpp | 80 +------ src/gtk1/app.cpp | 80 +------ src/mac/app.cpp | 112 +--------- src/mac/carbon/app.cpp | 112 +--------- src/mgl/app.cpp | 104 ++------- src/motif/app.cpp | 83 +------- src/msw/app.cpp | 469 ++++------------------------------------- src/msw/frame.cpp | 4 +- src/msw/main.cpp | 69 +++++- src/msw/mdi.cpp | 8 +- src/msw/utils.cpp | 45 ++++ src/msw/window.cpp | 2 +- src/os2/app.cpp | 124 ++--------- src/wxBase.dsp | 135 +++++++----- src/wxMSW.dsp | 8 +- src/wxWindows.dsp | 185 +++++++++------- src/x11/app.cpp | 77 +------ 34 files changed, 1037 insertions(+), 1576 deletions(-) create mode 100644 include/wx/init.h diff --git a/include/wx/app.h b/include/wx/app.h index a9bf03c287..5ed82cebef 100644 --- a/include/wx/app.h +++ b/include/wx/app.h @@ -24,6 +24,7 @@ #endif // wxUSE_GUI #include "wx/build.h" +#include "wx/init.h" class WXDLLEXPORT wxApp; class WXDLLEXPORT wxAppTraits; @@ -89,12 +90,22 @@ public: // the virtual functions which may/must be overridden in the derived class // ----------------------------------------------------------------------- + // This is the very first function called for a newly created wxApp object, + // it is used by the library to do the global initialization. If, for some + // reason, you must override it (instead of just overriding OnInit(), as + // usual, for app-specific initializations), do not forget to call the base + // class version! + virtual bool Initialize(int argc, wxChar **argv); + // Called before OnRun(), this is a good place to do initialization -- if // anything fails, return false from here to prevent the program from // continuing. The command line is normally parsed here, call the base // class OnInit() to do it. virtual bool OnInit(); + // this is here only temproary hopefully (FIXME) + virtual bool OnInitGui() { return true; } + // This is the replacement for the normal main(): all program work should // be done here. When OnRun() returns, the programs starts shutting down. virtual int OnRun() = 0; @@ -103,6 +114,11 @@ public: // any cleanup matching the initializations done there. virtual int OnExit(); + // This is the very last function called on wxApp object before it is + // destroyed. If you override it (instead of overriding OnExit() as usual) + // do not forget to call the base class version! + virtual void CleanUp(); + // Called when a fatal exception occurs, this function should take care not // to do anything which might provoke a nested exception! It may be // overridden if you wish to react somehow in non-default way (core dump @@ -295,6 +311,11 @@ public: // the virtual functions which may/must be overridden in the derived class // ----------------------------------------------------------------------- + // very first initialization function + // + // Override: very rarely + virtual bool Initialize(int argc, wxChar **argv); + // a platform-dependent version of OnInit(): the code here is likely to // depend on the toolkit. default version does nothing. // @@ -310,8 +331,10 @@ public: // Override: rarely in GUI applications, always in console ones. virtual int OnRun(); - // exit the main loop thus terminating the application - virtual void Exit(); + // very last clean up function + // + // Override: very rarely + virtual void CleanUp(); // the worker functions - usually not used directly by the user code @@ -320,6 +343,9 @@ public: // execute the main GUI loop, the function returns when the loop ends virtual int MainLoop() = 0; + // exit the main loop thus terminating the application + virtual void Exit(); + // exit the main GUI loop during the next iteration (i.e. it does not // stop the program immediately!) virtual void ExitMainLoop() = 0; @@ -419,6 +445,9 @@ public: protected: + // delete all objects in wxPendingDelete list + void DeletePendingObjects(); + // override base class method to use GUI traits virtual wxAppTraits *CreateTraits(); @@ -505,44 +534,6 @@ extern bool WXDLLEXPORT wxYield(); // Yield to other apps/messages extern void WXDLLEXPORT wxWakeUpIdle(); - -// console applications may avoid using DECLARE_APP and IMPLEMENT_APP macros -// and call these functions instead at the program startup and termination -// ------------------------------------------------------------------------- - -#if !wxUSE_GUI - -// initialize the library (may be called as many times as needed, but each -// call to wxInitialize() must be matched by wxUninitialize()) -extern bool WXDLLEXPORT wxInitialize(); - -// clean up - the library can't be used any more after the last call to -// wxUninitialize() -extern void WXDLLEXPORT wxUninitialize(); - -// create an object of this class on stack to initialize/cleanup thel ibrary -// automatically -class WXDLLEXPORT wxInitializer -{ -public: - // initialize the library - wxInitializer() { m_ok = wxInitialize(); } - - // has the initialization been successful? (explicit test) - bool IsOk() const { return m_ok; } - - // has the initialization been successful? (implicit test) - operator bool() const { return m_ok; } - - // dtor only does clean up if we initialized the library properly - ~wxInitializer() { if ( m_ok ) wxUninitialize(); } - -private: - bool m_ok; -}; - -#endif // !wxUSE_GUI - // ---------------------------------------------------------------------------- // macros for dynamic creation of the application object // ---------------------------------------------------------------------------- @@ -572,22 +563,17 @@ public: extern int wxEntry( int argc, char **argv, bool enterLoop = TRUE ); \ int main(int argc, char **argv) { return wxEntry(argc, argv); } #elif defined(__WXMSW__) && defined(WXUSINGDLL) - // NT defines APIENTRY, 3.x not - #if !defined(WXAPIENTRY) - #define WXAPIENTRY WXFAR wxSTDCALL - #endif - - #include - #include "wx/msw/winundef.h" - #define IMPLEMENT_WXWIN_MAIN \ - extern "C" int WXAPIENTRY WinMain(HINSTANCE hInstance,\ - HINSTANCE hPrevInstance,\ - LPSTR m_lpCmdLine, int nCmdShow)\ - {\ - return wxEntry((WXHINSTANCE) hInstance,\ - (WXHINSTANCE) hPrevInstance,\ - m_lpCmdLine, nCmdShow);\ + extern int wxEntry(WXHINSTANCE hInstance, \ + WXHINSTANCE hPrevInstance, \ + char *pCmdLine, \ + int nCmdShow); \ + extern "C" int wxSTDCALL WinMain(WXHINSTANCE hInstance, \ + WXHINSTANCE hPrevInstance, \ + char *lpCmdLine, \ + int nCmdShow) \ + { \ + return wxEntry(hInstance, hPrevInstance, lpCmdLine, nCmdShow); \ } #else #define IMPLEMENT_WXWIN_MAIN @@ -605,13 +591,14 @@ public: // Use this macro if you want to define your own main() or WinMain() function // and call wxEntry() from there. -#define IMPLEMENT_APP_NO_MAIN(appname) \ - wxApp *wxCreateApp() \ - { \ - wxApp::CheckBuildOptions(wxBuildOptions()); \ - return new appname; \ - } \ - wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \ +#define IMPLEMENT_APP_NO_MAIN(appname) \ + wxApp *wxCreateApp() \ + { \ + wxApp::CheckBuildOptions(wxBuildOptions()); \ + return new appname; \ + } \ + wxAppInitializer \ + wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \ appname& wxGetApp() { return *(appname *)wxTheApp; } // Same as IMPLEMENT_APP() normally but doesn't include themes support in @@ -630,5 +617,5 @@ public: // function #define DECLARE_APP(appname) extern appname& wxGetApp(); -#endif - // _WX_APP_H_BASE_ +#endif // _WX_APP_H_BASE_ + diff --git a/include/wx/apptrait.h b/include/wx/apptrait.h index 488645e1b1..dff9f3fdfc 100644 --- a/include/wx/apptrait.h +++ b/include/wx/apptrait.h @@ -116,7 +116,7 @@ public: // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps // ---------------------------------------------------------------------------- -class wxConsoleAppTraitsBase : public wxAppTraits +class WXDLLEXPORT wxConsoleAppTraitsBase : public wxAppTraits { public: #if wxUSE_LOG @@ -142,7 +142,7 @@ public: #if wxUSE_GUI -class wxGUIAppTraitsBase : public wxAppTraits +class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits { public: #if wxUSE_LOG diff --git a/include/wx/cocoa/app.h b/include/wx/cocoa/app.h index 357fda54f4..ffb6b3d82c 100644 --- a/include/wx/cocoa/app.h +++ b/include/wx/cocoa/app.h @@ -66,12 +66,11 @@ public: // Returns TRUE if more idle time is requested. bool SendIdleEvents(wxWindowCocoa* win); - static bool Initialize(); - static void CleanUp(); + virtual bool Initialize(int argc, wxChar **argv); + virtual void CleanUp(); virtual bool OnInit(); virtual bool OnInitGui(); - void DeletePendingObjects(); }; #endif // _WX_COCOA_APP_H_ diff --git a/include/wx/gtk/app.h b/include/wx/gtk/app.h index fbd5a55e6a..fea48cf032 100644 --- a/include/wx/gtk/app.h +++ b/include/wx/gtk/app.h @@ -58,11 +58,10 @@ public: bool SendIdleEvents(); bool SendIdleEvents( wxWindow* win ); - static bool Initialize(); - static bool InitialzeVisual(); - static void CleanUp(); + virtual bool Initialize(int argc, wxChar **argv); + virtual void CleanUp(); - void DeletePendingObjects(); + static bool InitialzeVisual(); #ifdef __WXDEBUG__ virtual void OnAssert(const wxChar *file, int line, const wxChar *cond, const wxChar *msg); diff --git a/include/wx/gtk1/app.h b/include/wx/gtk1/app.h index fbd5a55e6a..fea48cf032 100644 --- a/include/wx/gtk1/app.h +++ b/include/wx/gtk1/app.h @@ -58,11 +58,10 @@ public: bool SendIdleEvents(); bool SendIdleEvents( wxWindow* win ); - static bool Initialize(); - static bool InitialzeVisual(); - static void CleanUp(); + virtual bool Initialize(int argc, wxChar **argv); + virtual void CleanUp(); - void DeletePendingObjects(); + static bool InitialzeVisual(); #ifdef __WXDEBUG__ virtual void OnAssert(const wxChar *file, int line, const wxChar *cond, const wxChar *msg); diff --git a/include/wx/init.h b/include/wx/init.h new file mode 100644 index 0000000000..f973e9b0f3 --- /dev/null +++ b/include/wx/init.h @@ -0,0 +1,83 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/init.h +// Purpose: wxWindows initialization and finalization functions +// Author: Vadim Zeitlin +// Modified by: +// Created: 29.06.2003 +// RCS-ID: $Id$ +// Copyright: (c) 2003 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_INIT_H_ +#define _WX_INIT_H_ + +#include "wx/wxchar.h" + +// ---------------------------------------------------------------------------- +// wxEntry helper functions which allow to have more fine grained control +// ---------------------------------------------------------------------------- + +// do common initialization, return true if ok (in this case wxEntryCleanup +// must be called later), otherwise the program can't use wxWindows at all +// +// this function also creates wxTheApp as a side effect, if IMPLEMENT_APP +// hadn't been used a dummy default application object is created +// +// note that the parameters may be modified +extern bool WXDLLEXPORT wxEntryStart(int argc, wxChar **argv); + +// free the resources allocated by the library in wxEntryStart() and shut it +// down (wxEntryStart() may be called again afterwards if necessary) +extern void WXDLLEXPORT wxEntryCleanup(); + + +// ---------------------------------------------------------------------------- +// wxEntry: this function initializes the library, runs the main event loop +// and cleans it up +// ---------------------------------------------------------------------------- + +// note that other, platform-specific, overloads of wxEntry may exist as well +// but this one always exists under all platforms +// +// returns the program exit code +extern int WXDLLEXPORT wxEntry(int argc, wxChar **argv); + + +// ---------------------------------------------------------------------------- +// Using the library without (explicit) application object: you may avoid using +// DECLARE_APP and IMPLEMENT_APP macros and call the functions below instead at +// the program startup and termination +// ---------------------------------------------------------------------------- + +// initialize the library (may be called as many times as needed, but each +// call to wxInitialize() must be matched by wxUninitialize()) +extern bool WXDLLEXPORT wxInitialize(int argc = 0, wxChar **argv = NULL); + +// clean up -- the library can't be used any more after the last call to +// wxUninitialize() +extern void WXDLLEXPORT wxUninitialize(); + +// create an object of this class on stack to initialize/cleanup the library +// automatically +class WXDLLEXPORT wxInitializer +{ +public: + // initialize the library + wxInitializer() { m_ok = wxInitialize(); } + + // has the initialization been successful? (explicit test) + bool IsOk() const { return m_ok; } + + // has the initialization been successful? (implicit test) + operator bool() const { return m_ok; } + + // dtor only does clean up if we initialized the library properly + ~wxInitializer() { if ( m_ok ) wxUninitialize(); } + +private: + bool m_ok; +}; + +#endif // _WX_INIT_H_ + diff --git a/include/wx/mac/app.h b/include/wx/mac/app.h index 389d6b0d8a..592e797f3f 100644 --- a/include/wx/mac/app.h +++ b/include/wx/mac/app.h @@ -91,10 +91,9 @@ protected: public: // Implementation - static bool Initialize(); - static void CleanUp(); + virtual bool Initialize(int argc, wxChar **argv); + virtual void CleanUp(); - void DeletePendingObjects(); bool IsExiting() { return !m_keepGoing ; } #if TARGET_CARBON WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; } diff --git a/include/wx/mgl/app.h b/include/wx/mgl/app.h index 43bec77767..ea3a377ab6 100644 --- a/include/wx/mgl/app.h +++ b/include/wx/mgl/app.h @@ -54,10 +54,8 @@ public: bool SendIdleEvents(); bool SendIdleEvents(wxWindow* win); - static bool Initialize(); - static void CleanUp(); - - void DeletePendingObjects(); + virtual bool Initialize(int argc, wxChar **argv); + virtual void CleanUp(); virtual bool Yield(bool onlyIfNeeded = FALSE); diff --git a/include/wx/motif/app.h b/include/wx/motif/app.h index 1e24fb47ce..8f8b632ba8 100644 --- a/include/wx/motif/app.h +++ b/include/wx/motif/app.h @@ -82,10 +82,8 @@ protected: public: // Implementation - static bool Initialize(); - static void CleanUp(); - - void DeletePendingObjects(); + virtual bool Initialize(int argc, wxChar **argv); + virtual void CleanUp(); // Motif-specific WXAppContext GetAppContext() const { return m_appContext; } diff --git a/include/wx/msw/app.h b/include/wx/msw/app.h index 8f384d947b..756430f73c 100644 --- a/include/wx/msw/app.h +++ b/include/wx/msw/app.h @@ -36,6 +36,9 @@ public: virtual ~wxApp(); // override base class (pure) virtuals + virtual bool Initialize(int argc, wxChar **argv); + virtual void CleanUp(); + virtual int MainLoop(); virtual void ExitMainLoop(); virtual bool Initialized(); @@ -62,28 +65,17 @@ public: // Returns TRUE if more idle time is requested. bool SendIdleEvents(wxWindow* win); - void SetAuto3D(bool flag) { m_auto3D = flag; } - bool GetAuto3D() const { return m_auto3D; } - protected: - bool m_showOnInit; int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT - bool m_auto3D ; // Always use 3D controls, except where overriden /* Windows-specific wxApp definitions */ public: // Implementation - static bool Initialize(); - static void CleanUp(); - static bool RegisterWindowClasses(); static bool UnregisterWindowClasses(); - // Convert Windows to argc, argv style - void ConvertToStandardCommandArgs(const char* p); - // message processing // ------------------ @@ -99,8 +91,6 @@ public: // idle processing // --------------- - void DeletePendingObjects(); - #if wxUSE_RICHEDIT // initialize the richedit DLL of (at least) given version, return TRUE if // ok (Win95 has version 1, Win98/NT4 has 1 and 2, W2K has 3) @@ -112,21 +102,19 @@ public: static int GetComCtl32Version(); public: - int m_nCmdShow; + // the SW_XXX value to be used for the frames opened by the application + // (currently seems unused which is a bug -- TODO) + static int m_nCmdShow; protected: - bool m_keepGoing; + // we exit the main event loop when this flag becomes false + bool m_keepGoing; DECLARE_EVENT_TABLE() }; -#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL)) int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance, - char *lpszCmdLine, int nCmdShow, bool enterLoop = TRUE); -#else -int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance); -#endif + char *lpszCmdLine, int nCmdShow); -#endif - // _WX_APP_H_ +#endif // _WX_APP_H_ diff --git a/include/wx/os2/app.h b/include/wx/os2/app.h index db41f62a49..915e1a1267 100644 --- a/include/wx/os2/app.h +++ b/include/wx/os2/app.h @@ -126,14 +126,13 @@ private: public: // Implementation - static bool Initialize(HAB vHab); - static void CleanUp(void); + virtual bool Initialize(int argc, wxChar **argv); + virtual void CleanUp(void); static bool RegisterWindowClasses(HAB vHab); virtual void DoMessage(WXMSG *pMsg); virtual bool DoMessage(void); virtual bool ProcessMessage(WXMSG* pMsg); - void DeletePendingObjects(void); public: int m_nCmdShow; diff --git a/include/wx/x11/app.h b/include/wx/x11/app.h index 20e3dfb2b5..d8d709a77a 100644 --- a/include/wx/x11/app.h +++ b/include/wx/x11/app.h @@ -89,8 +89,8 @@ protected: public: // Implementation - static bool Initialize(); - static void CleanUp(); + virtual bool Initialize(); + virtual void CleanUp(); void DeletePendingObjects(); diff --git a/src/cocoa/app.mm b/src/cocoa/app.mm index d25e9d3230..8532a12f94 100644 --- a/src/cocoa/app.mm +++ b/src/cocoa/app.mm @@ -231,84 +231,23 @@ END_EVENT_TABLE() // ---------------------------------------------------------------------------- // wxApp static functions // ---------------------------------------------------------------------------- -/*static*/ bool wxApp::Initialize() + +bool wxApp::Initialize(int argc, wxChar **argv) { + // VZ: apparently this needs to be done a.s.a.p., right? it is done after + // wxClassInfo::InitializeClasses() now but usd to be done before, I + // hope it's not a problem -- if it is, please let me know, David (if + // it isn't, just remove this comment :-) wxPoseAsInitializer::InitializePosers(); - wxClassInfo::InitializeClasses(); - -#if wxUSE_THREADS - wxPendingEventsLocker = new wxCriticalSection; -#endif - wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); - wxTheColourDatabase->Initialize(); - - wxInitializeStockLists(); - wxInitializeStockObjects(); - -#if wxUSE_WX_RESOURCES - wxInitializeResourceSystem(); -#endif - - wxBitmap::InitStandardHandlers(); - - wxModule::RegisterModules(); - if (!wxModule::InitializeModules()) { - return FALSE; - } - return TRUE; + return wxAppBase::Initialize(argc, argv); } -/*static*/ void wxApp::CleanUp() +void wxApp::CleanUp() { - wxModule::CleanUpModules(); - -#if wxUSE_WX_RESOURCES - wxCleanUpResourceSystem(); -#endif - - wxDeleteStockObjects() ; - - // Destroy all GDI lists, etc. - wxDeleteStockLists(); - - delete wxTheColourDatabase; - wxTheColourDatabase = NULL; - - wxBitmap::CleanUpHandlers(); - - delete wxPendingEvents; - -#if wxUSE_THREADS - delete wxPendingEventsLocker; - // If we don't do the following, we get an apparent memory leak. - ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker(); -#endif - - 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(TRUE) > 0) - { - wxLogDebug(wxT("There were memory leaks.")); - wxDebugContext::Dump(); - wxDebugContext::PrintStatistics(); - } - // wxDebugContext::SetStream(NULL, NULL); -#endif - wxDC::CocoaShutdownTextSystem(); -#if wxUSE_LOG - // do it as the very last thing because everything else can log messages - delete wxLog::SetActiveTarget(NULL); -#endif // wxUSE_LOG + + wxAppBase::CleanUp(); } // ---------------------------------------------------------------------------- @@ -521,21 +460,3 @@ bool wxApp::Yield(bool onlyIfNeeded) return true; } -void wxApp::DeletePendingObjects() -{ - wxNode *node = wxPendingDelete.GetFirst(); - while (node) - { - wxObject *obj = (wxObject *)node->GetData(); - - delete obj; - - if (wxPendingDelete.Find(obj)) - delete node; - - node = wxPendingDelete.GetFirst(); - } -} - -// platform specifics - diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 271e3cd7e5..99708fd85e 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -36,6 +36,9 @@ #include "wx/apptrait.h" #include "wx/cmdline.h" #include "wx/confbase.h" +#if wxUSE_FILENAME + #include "wx/filename.h" +#endif // wxUSE_FILENAME #if wxUSE_FONTMAP #include "wx/fontmap.h" #endif // wxUSE_FONTMAP @@ -114,6 +117,33 @@ wxAppConsole::~wxAppConsole() delete m_traits; } +// ---------------------------------------------------------------------------- +// initilization/cleanup +// ---------------------------------------------------------------------------- + +bool wxAppConsole::Initialize(int argc, wxChar **argv) +{ + // remember the command line arguments + this->argc = argc; + this->argv = argv; + + if ( m_appName.empty() ) + { + // the application name is, by default, the name of its executable file +#if wxUSE_FILENAME + wxFileName::SplitPath(argv[0], NULL, &m_appName, NULL); +#else // !wxUSE_FILENAME + m_appName = argv[0]; +#endif // wxUSE_FILENAME/!wxUSE_FILENAME + } + + return true; +} + +void wxAppConsole::CleanUp() +{ +} + // ---------------------------------------------------------------------------- // OnXXX() callbacks // ---------------------------------------------------------------------------- diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index b179284223..21466c15ec 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -49,7 +49,7 @@ // ============================================================================ // ---------------------------------------------------------------------------- -// initialization and termination +// initialization // ---------------------------------------------------------------------------- wxAppBase::wxAppBase() @@ -73,11 +73,75 @@ wxAppBase::wxAppBase() m_exitOnFrameDelete = Later; } +bool wxAppBase::Initialize(int argc, wxChar **argv) +{ + if ( !wxAppConsole::Initialize(argc, argv) ) + return false; + + // for compatibility call the old initialization function too + if ( !OnInitGui() ) + { + wxAppConsole::CleanUp(); + + return false; + } + +#if wxUSE_THREADS + wxPendingEventsLocker = new wxCriticalSection; +#endif + + wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); + wxTheColourDatabase->Initialize(); + + wxInitializeStockLists(); + wxInitializeStockObjects(); + + wxBitmap::InitStandardHandlers(); + + return true; +} + +// ---------------------------------------------------------------------------- +// cleanup +// ---------------------------------------------------------------------------- + wxAppBase::~wxAppBase() { // this destructor is required for Darwin } +void wxAppBase::CleanUp() +{ + // one last chance for pending objects to be cleaned up + DeletePendingObjects(); + + wxBitmap::CleanUpHandlers(); + + wxDeleteStockObjects(); + + wxDeleteStockLists(); + + delete wxTheColourDatabase; + wxTheColourDatabase = NULL; + +#if wxUSE_THREADS + delete wxPendingEvents; + wxPendingEvents = NULL; + + delete wxPendingEventsLocker; + wxPendingEventsLocker = NULL; + +#if wxUSE_VALIDATORS + // If we don't do the following, we get an apparent memory leak. + ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker(); +#endif // wxUSE_VALIDATORS +#endif // wxUSE_THREADS +} + +// ---------------------------------------------------------------------------- +// OnXXX() hooks +// ---------------------------------------------------------------------------- + bool wxAppBase::OnInitGui() { #ifdef __WXUNIVERSAL__ @@ -128,6 +192,24 @@ void wxAppBase::SetActive(bool active, wxWindow * WXUNUSED(lastFocus)) (void)ProcessEvent(event); } +void wxAppBase::DeletePendingObjects() +{ + wxNode *node = wxPendingDelete.GetFirst(); + while (node) + { + wxObject *obj = node->GetData(); + + delete obj; + + if (wxPendingDelete.Member(obj)) + delete node; + + // Deleting one object may have deleted other pending + // objects, so start from beginning of list again. + node = wxPendingDelete.GetFirst(); + } +} + // ---------------------------------------------------------------------------- // wxGUIAppTraitsBase // ---------------------------------------------------------------------------- diff --git a/src/common/fs_mem.cpp b/src/common/fs_mem.cpp index d6b020b2ab..a1013b5bde 100644 --- a/src/common/fs_mem.cpp +++ b/src/common/fs_mem.cpp @@ -19,10 +19,12 @@ #if wxUSE_FILESYSTEM && wxUSE_STREAMS -#include "wx/image.h" -#include "wx/bitmap.h" #include "wx/fs_mem.h" +#if wxUSE_GUI + #include "wx/image.h" + #include "wx/bitmap.h" +#endif // wxUSE_GUI #ifndef WXPRECOMP #include "wx/intl.h" diff --git a/src/common/init.cpp b/src/common/init.cpp index b3cd9aa66d..e696eacb12 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -28,189 +28,419 @@ #include "wx/debug.h" #include "wx/filefn.h" #include "wx/log.h" + #include "wx/thread.h" #endif +#include "wx/ptr_scpd.h" #include "wx/module.h" +#if defined(__WXMSW__) && defined(__WXDEBUG__) + #include "wx/msw/msvcrt.h" + + static struct EnableMemLeakChecking + { + EnableMemLeakChecking() + { + // 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); + } + } gs_enableLeakChecks; +#endif // __WXMSW__ && __WXDEBUG__ + // ---------------------------------------------------------------------------- // private classes // ---------------------------------------------------------------------------- // we need a dummy app object if the user doesn't want to create a real one -class wxDummyConsoleApp : public wxApp +class wxDummyConsoleApp : public wxAppConsole { public: virtual int OnRun() { wxFAIL_MSG( _T("unreachable code") ); return 0; } }; -// ---------------------------------------------------------------------------- -// private functions -// ---------------------------------------------------------------------------- +// we need a special kind of auto pointer to wxApp which not only deletes the +// pointer it holds in its dtor but also resets wxTheApp +wxDECLARE_SCOPED_PTR(wxApp, wxAppPtrBase); +wxDEFINE_SCOPED_PTR(wxApp, wxAppPtrBase); -static bool DoInit(); -static void DoCleanUp(); +class wxAppPtr : public wxAppPtrBase +{ +public: + wxEXPLICIT wxAppPtr(wxApp *ptr = NULL) : wxAppPtrBase(ptr) { } + ~wxAppPtr() + { + if ( get() ) + { + // the pointer is going to be deleted in the base class dtor, don't + // leave the dangling pointer! + wxTheApp = NULL; + } + } + + void Set(wxApp *ptr) + { + reset(ptr); + + wxTheApp = ptr; + } +}; + +// another tiny class which simply exists to ensure that wxEntryCleanup is +// always called +class wxCleanupOnExit +{ +public: + ~wxCleanupOnExit() { wxEntryCleanup(); } +}; // ---------------------------------------------------------------------------- -// private vars +// initialization data // ---------------------------------------------------------------------------- -static size_t gs_nInitCount = 0; +static struct InitData +{ + InitData() + { + nInitCount = 0; + +#if wxUSE_UNICODE + argc = 0; + // argv = NULL; -- not even really needed +#endif // wxUSE_UNICODE + } + + // critical section protecting this struct + wxCRIT_SECT_DECLARE_MEMBER(csInit); + + // number of times wxInitialize() was called minus the number of times + // wxUninitialize() was + size_t nInitCount; + +#if wxUSE_UNICODE + int argc; + + // if we receive the command line arguments as ASCII and have to convert + // them to Unicode ourselves (this is the case under Unix but not Windows, + // for example), we remember the converted argv here because we'll have to + // free it when doing cleanup to avoid memory leaks + wchar_t *argv; +#endif // wxUSE_UNICODE +} gs_initData; // ============================================================================ // implementation // ============================================================================ // ---------------------------------------------------------------------------- -// wxBase-specific functions +// command line arguments ANSI -> Unicode conversion // ---------------------------------------------------------------------------- -bool WXDLLEXPORT wxInitialize() +#if wxUSE_UNICODE + +static void ConvertArgsToUnicode(int argc, char **argv) { - if ( gs_nInitCount ) + gs_initData.argv = new wchar_t *[argc + 1]; + for ( int i = 0; i < argc; i++ ) { - // already initialized - return TRUE; + gs_initData.argv[i] = wxStrdup(wxConvLocal.cMB2WX(argv[i])); } - wxASSERT_MSG( !wxTheApp, - wxT("either call wxInitialize or create app, not both!") ); + gs_initData.argv[argc] = NULL; +} - if ( !DoInit() ) +static void FreeConvertedArgs() +{ + for ( int mb_argc = 0; mb_argc < wxTheApp->argc; mb_argc++ ) { - return FALSE; + free(wxTheApp->argv[mb_argc]); } +} - wxTheApp = new wxDummyConsoleApp; +#endif // wxUSE_UNICODE - if ( !wxTheApp ) - { - return FALSE; - } +// ---------------------------------------------------------------------------- +// start up +// ---------------------------------------------------------------------------- - gs_nInitCount++; +// initialization which is always done (not customizable) before wxApp creation +static bool DoCommonPreInit() +{ + wxClassInfo::InitializeClasses(); - return TRUE; + return true; } -void WXDLLEXPORT wxUninitialize() +// non customizable initialization done after wxApp creation and initialization +static bool DoCommonPostInit() { - if ( !--gs_nInitCount ) - { - DoCleanUp(); - } + wxModule::RegisterModules(); + + return wxModule::InitializeModules(); } -int wxEntry(int argc, char **argv) +bool wxEntryStart(int argc, wxChar **argv) { - // library initialization - if ( !DoInit() ) + // do minimal, always necessary, initialization + // -------------------------------------------- + + // initialize wxRTTI + if ( !DoCommonPreInit() ) { - return -1; + return false; } - // create the app - if ( !wxTheApp ) - { - wxCHECK_MSG( wxApp::GetInitializerFunction(), -1, - wxT("No application object: use IMPLEMENT_APP macro.") ); + // first of all, we need an application object + // ------------------------------------------- + + // the user might have already created it himself somehow + wxAppPtr app(wxTheApp); + if ( !app.get() ) + { + // if not, he might have used IMPLEMENT_APP() to give us a function to + // create it wxAppInitializerFunction fnCreate = wxApp::GetInitializerFunction(); - wxTheApp = (wxApp *)fnCreate(); + if ( fnCreate ) + { + // he did, try to create the custom wxApp object + app.Set((*fnCreate)()); + } + } + + if ( !app.get() ) + { + // either IMPLEMENT_APP() was not used at all or it failed -- in any + // case we still need something + // + // NB: cast is needed because for the backwards-compatibility reasons + // wxTheApp is really a wxApp and not just wxAppConsole... + app.Set((wxApp *)new wxDummyConsoleApp); } - wxCHECK_MSG( wxTheApp, -1, wxT("wxWindows error: no application object") ); - // app preinitialization - wxTheApp->argc = argc; + // wxApp initialization: this can be customized + // -------------------------------------------- -#if wxUSE_UNICODE - wxTheApp->argv = new wxChar*[argc+1]; - for ( int mb_argc = 0; mb_argc < argc; mb_argc++ ) + if ( !wxTheApp->Initialize(argc, argv) ) { - wxTheApp->argv[mb_argc] = wxStrdup(wxConvLocal.cMB2WX(argv[mb_argc])); + return false; } - wxTheApp->argv[mb_argc] = (wxChar *)NULL; -#else - wxTheApp->argv = argv; -#endif - wxString name = wxFileNameFromPath(wxTheApp->argv[0]); - wxStripExtension(name); - wxTheApp->SetAppName(name); - int retValue = 0; - - // app initialization - if ( !wxTheApp->OnInit() ) - retValue = -1; + // common initialization after wxTheApp creation + // --------------------------------------------- - // app execution - if ( retValue == 0 ) + if ( !DoCommonPostInit() ) { - retValue = wxTheApp->OnRun(); - - // app clean up - wxTheApp->OnExit(); + return false; } - // library clean up - DoCleanUp(); - return retValue; + // prevent the smart pointer from destroying its contents + app.release(); + + return true; } -// ---------------------------------------------------------------------------- -// private functions -// ---------------------------------------------------------------------------- +#if wxUSE_UNICODE -static bool DoInit() +// we provide a wxEntryStart() wrapper taking "char *" pointer too +bool wxEntryStart(int argc, char **argv) { - wxClassInfo::InitializeClasses(); + ConvertArgsToUnicode(argc, argv); - wxModule::RegisterModules(); - if ( !wxModule::InitializeModules() ) + if ( !wxEntryStart(argc, gs_initData.argv) ) { - return FALSE; + FreeConvertedArgs(); + + return false; } - return TRUE; + return true; } -static void DoCleanUp() +#endif // wxUSE_UNICODE + +// ---------------------------------------------------------------------------- +// clean up +// ---------------------------------------------------------------------------- + +// cleanup done before destroying wxTheApp +static void DoCommonPreCleanup() { #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 + // 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) 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() +{ wxClassInfo::CleanUpClasses(); - // TODO: this should really be done in ~wxApp + // we can't do this in wxApp itself because it doesn't know if argv had + // been allocated #if wxUSE_UNICODE - for ( int mb_argc = 0; mb_argc < wxTheApp->argc; mb_argc++ ) - { - free(wxTheApp->argv[mb_argc]); - } + FreeConvertedArgs(); #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 } +void wxEntryCleanup() +{ + DoCommonPreCleanup(); + + + // delete the application object + if ( wxTheApp ) + { + wxTheApp->CleanUp(); + + delete wxTheApp; + wxTheApp = NULL; + } + + + DoCommonPostCleanup(); + + // 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 + +} + +// ---------------------------------------------------------------------------- +// wxEntry +// ---------------------------------------------------------------------------- + +#if !defined(__WXMSW__) || !wxUSE_ON_FATAL_EXCEPTION + #define wxEntryReal wxEntry +#endif // !(__WXMSW__ && wxUSE_ON_FATAL_EXCEPTION) + +int wxEntryReal(int argc, wxChar **argv) +{ + // library initialization + if ( !wxEntryStart(argc, argv) ) + { + return -1; + } + + // if wxEntryStart succeeded, we must call wxEntryCleanup even if the code + // below returns or throws + wxCleanupOnExit cleanupOnExit; + + // app initialization + if ( !wxTheApp->OnInit() ) + { + // don't call OnExit() if OnInit() failed + return -1; + } + + // app execution + int retValue = wxTheApp->OnRun(); + + // why should we do this? it doesn't close all window, just one of them and + // this shouldn't be necessary anyhow... +#if 0 + // close any remaining windows + wxWindow *topWindow = wxTheApp->GetTopWindow(); + if ( topWindow ) + { + // forcibly delete the window. + topWindow->Destroy(); + + // collect the dead objects + wxTheApp->DeletePendingObjects(); + } +#endif // 0 + + // app clean up + wxTheApp->OnExit(); + + return retValue; +} + +// wrap real wxEntry in a try-except block to be able to call +// OnFatalException() if necessary +#if defined(__WXMSW__) && wxUSE_ON_FATAL_EXCEPTION + +extern unsigned long wxGlobalSEHandler(); + +int wxEntry(int argc, wxChar **argv) +{ + __try + { + return wxEntryReal(argc, argv); + } + __except ( wxGlobalSEHandler() ) + { + ::ExitProcess(3); // the same exit code as abort() + + // this code is unreachable but put it here to suppress warnings + return -1; + } +} + +#endif // __WXMSW__ && wxUSE_ON_FATAL_EXCEPTION + +#if wxUSE_UNICODE + +// as with wxEntryStart, we provide an ANSI wrapper +int wxEntry(int argc, char **argv) +{ + ConvertArgsToUnicode(argc, argv); + + return wxEntry(argc, gs_initData.argv); +} + +#endif // wxUSE_UNICODE + +// ---------------------------------------------------------------------------- +// wxInitialize/wxUninitialize +// ---------------------------------------------------------------------------- + +bool wxInitialize(int argc, wxChar **argv) +{ + wxCRIT_SECT_LOCKER(lockInit, gs_initData.csInit); + + if ( gs_initData.nInitCount++ ) + { + // already initialized + return true; + } + + return wxEntryStart(argc, argv); +} + +void wxUninitialize() +{ + wxCRIT_SECT_LOCKER(lockInit, gs_initData.csInit); + + if ( !--gs_initData.nInitCount ) + { + wxEntryCleanup(); + } +} + diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index a7b0428703..a062fd79bf 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -671,91 +671,21 @@ void wxApp::Dispatch() gtk_main_iteration(); } -void wxApp::DeletePendingObjects() +bool wxApp::Initialize(int argc, wxChar **argv) { - wxNode *node = wxPendingDelete.GetFirst(); - while (node) - { - wxObject *obj = (wxObject *)node->GetData(); - - delete obj; - - if (wxPendingDelete.Find(obj)) - delete node; - - node = wxPendingDelete.GetFirst(); - } -} - -bool wxApp::Initialize() -{ - wxClassInfo::InitializeClasses(); - - // GL: I'm annoyed ... I don't know where to put this and I don't want to - // create a module for that as it's part of the core. -#if wxUSE_THREADS - wxPendingEvents = new wxList(); - wxPendingEventsLocker = new wxCriticalSection(); -#endif - - wxTheColourDatabase = new wxColourDatabase( wxKEY_STRING ); - wxTheColourDatabase->Initialize(); - - wxInitializeStockLists(); - wxInitializeStockObjects(); - - wxModule::RegisterModules(); - if (!wxModule::InitializeModules()) - return FALSE; + if ( !wxAppBase::Initialize(argc, argv) ) + return false; #if wxUSE_INTL wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); #endif - return TRUE; + return true; } void wxApp::CleanUp() { - wxModule::CleanUpModules(); - - delete wxTheColourDatabase; - wxTheColourDatabase = (wxColourDatabase*) NULL; - - wxDeleteStockObjects(); - - wxDeleteStockLists(); - - delete wxTheApp; - wxTheApp = (wxApp*) NULL; - - wxClassInfo::CleanUpClasses(); - -#if wxUSE_THREADS - delete wxPendingEvents; - wxPendingEvents = NULL; - delete wxPendingEventsLocker; - wxPendingEventsLocker = NULL; -#endif - - // 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 - -#if wxUSE_LOG - // do this as the very last thing because everything else can log messages - wxLog::DontCreateOnDemand(); - - wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL ); - if (oldLog) - delete oldLog; -#endif // wxUSE_LOG + wxAppBase::CleanUp(); } //----------------------------------------------------------------------------- diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index a7b0428703..a062fd79bf 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -671,91 +671,21 @@ void wxApp::Dispatch() gtk_main_iteration(); } -void wxApp::DeletePendingObjects() +bool wxApp::Initialize(int argc, wxChar **argv) { - wxNode *node = wxPendingDelete.GetFirst(); - while (node) - { - wxObject *obj = (wxObject *)node->GetData(); - - delete obj; - - if (wxPendingDelete.Find(obj)) - delete node; - - node = wxPendingDelete.GetFirst(); - } -} - -bool wxApp::Initialize() -{ - wxClassInfo::InitializeClasses(); - - // GL: I'm annoyed ... I don't know where to put this and I don't want to - // create a module for that as it's part of the core. -#if wxUSE_THREADS - wxPendingEvents = new wxList(); - wxPendingEventsLocker = new wxCriticalSection(); -#endif - - wxTheColourDatabase = new wxColourDatabase( wxKEY_STRING ); - wxTheColourDatabase->Initialize(); - - wxInitializeStockLists(); - wxInitializeStockObjects(); - - wxModule::RegisterModules(); - if (!wxModule::InitializeModules()) - return FALSE; + if ( !wxAppBase::Initialize(argc, argv) ) + return false; #if wxUSE_INTL wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); #endif - return TRUE; + return true; } void wxApp::CleanUp() { - wxModule::CleanUpModules(); - - delete wxTheColourDatabase; - wxTheColourDatabase = (wxColourDatabase*) NULL; - - wxDeleteStockObjects(); - - wxDeleteStockLists(); - - delete wxTheApp; - wxTheApp = (wxApp*) NULL; - - wxClassInfo::CleanUpClasses(); - -#if wxUSE_THREADS - delete wxPendingEvents; - wxPendingEvents = NULL; - delete wxPendingEventsLocker; - wxPendingEventsLocker = NULL; -#endif - - // 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 - -#if wxUSE_LOG - // do this as the very last thing because everything else can log messages - wxLog::DontCreateOnDemand(); - - wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL ); - if (oldLog) - delete oldLog; -#endif // wxUSE_LOG + wxAppBase::CleanUp(); } //----------------------------------------------------------------------------- diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 39086ddeb8..9c3502089d 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -447,7 +447,7 @@ DEFINE_ONE_SHOT_HANDLER_GETTER( wxAppEventHandler ) WXIMPORT char std::__throws_bad_alloc ; #endif -bool wxApp::Initialize() +bool wxApp::Initialize(int argc, wxChar **argv) { int error = 0 ; @@ -535,37 +535,17 @@ bool wxApp::Initialize() s_macCursorRgn = ::NewRgn() ; - wxClassInfo::InitializeClasses(); - -#if wxUSE_RESOURCES -// wxGetResource(wxT("wxWindows"), wxT("OsVersion"), &wxOsVersion); -#endif - -#if wxUSE_THREADS - wxPendingEventsLocker = new wxCriticalSection; -#endif - - wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); - wxTheColourDatabase->Initialize(); + if ( !wxAppBase::Initialize(argc, argv) ) + return false; wxWinMacWindowList = new wxList(wxKEY_INTEGER); wxWinMacControlList = new wxList(wxKEY_INTEGER); - wxInitializeStockLists(); - wxInitializeStockObjects(); - - wxBitmap::InitStandardHandlers(); - - wxModule::RegisterModules(); - if (!wxModule::InitializeModules()) { - return FALSE; - } - wxMacCreateNotifierTable() ; UMAShowArrowCursor() ; - return TRUE; + return true; } bool wxApp::OnInitGui() @@ -615,51 +595,17 @@ bool wxApp::OnInitGui() void wxApp::CleanUp() { wxToolTip::RemoveToolTips() ; -#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 suppliedo ne might be even more unsafe (using any - // wxWindows 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 // One last chance for pending objects to be cleaned up wxTheApp->DeletePendingObjects(); - wxModule::CleanUpModules(); - - wxDeleteStockObjects() ; - - // Destroy all GDI lists, etc. - wxDeleteStockLists(); - - delete wxTheColourDatabase; - wxTheColourDatabase = NULL; - - wxBitmap::CleanUpHandlers(); - wxMacDestroyNotifierTable() ; - if (wxWinMacWindowList) { - delete wxWinMacWindowList ; - } - if (wxWinMacControlList) { - delete wxWinMacControlList ; - } - delete wxPendingEvents; - wxPendingEvents = NULL; -#if wxUSE_THREADS - delete wxPendingEventsLocker; - // There is still more cleanup code that will try to use this if not NULL. - wxPendingEventsLocker = NULL; - // If we don't do the following, we get an apparent memory leak. - ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker(); -#endif + delete wxWinMacWindowList ; + wxWinMacWindowList = NULL; - wxClassInfo::CleanUpClasses(); + delete wxWinMacControlList ; + wxWinMacControlList = NULL; #ifndef __DARWIN__ # if __option(profile) @@ -668,28 +614,6 @@ void wxApp::CleanUp() # endif #endif - 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(TRUE) > 0) - { - wxLogDebug(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 - #if defined(WXMAKINGDLL) && defined(__DARWIN__) // close shared library resources from here since we don't have // __wxterminate in Mach-O shared libraries @@ -705,6 +629,8 @@ void wxApp::CleanUp() #if 0 TerminateAE() ; #endif + + wxAppBase::CleanUp(); } //---------------------------------------------------------------------- @@ -1266,24 +1192,6 @@ bool wxApp::SendIdleEvents(wxWindow* win) return needMore ; } -void wxApp::DeletePendingObjects() -{ - wxNode *node = wxPendingDelete.GetFirst(); - while (node) - { - wxObject *obj = (wxObject *)node->GetData(); - - delete obj; - - if (wxPendingDelete.Member(obj)) - delete node; - - // Deleting one object may have deleted other pending - // objects, so start from beginning of list again. - node = wxPendingDelete.GetFirst(); - } -} - void wxApp::Exit() { wxApp::CleanUp(); diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index 39086ddeb8..9c3502089d 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -447,7 +447,7 @@ DEFINE_ONE_SHOT_HANDLER_GETTER( wxAppEventHandler ) WXIMPORT char std::__throws_bad_alloc ; #endif -bool wxApp::Initialize() +bool wxApp::Initialize(int argc, wxChar **argv) { int error = 0 ; @@ -535,37 +535,17 @@ bool wxApp::Initialize() s_macCursorRgn = ::NewRgn() ; - wxClassInfo::InitializeClasses(); - -#if wxUSE_RESOURCES -// wxGetResource(wxT("wxWindows"), wxT("OsVersion"), &wxOsVersion); -#endif - -#if wxUSE_THREADS - wxPendingEventsLocker = new wxCriticalSection; -#endif - - wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); - wxTheColourDatabase->Initialize(); + if ( !wxAppBase::Initialize(argc, argv) ) + return false; wxWinMacWindowList = new wxList(wxKEY_INTEGER); wxWinMacControlList = new wxList(wxKEY_INTEGER); - wxInitializeStockLists(); - wxInitializeStockObjects(); - - wxBitmap::InitStandardHandlers(); - - wxModule::RegisterModules(); - if (!wxModule::InitializeModules()) { - return FALSE; - } - wxMacCreateNotifierTable() ; UMAShowArrowCursor() ; - return TRUE; + return true; } bool wxApp::OnInitGui() @@ -615,51 +595,17 @@ bool wxApp::OnInitGui() void wxApp::CleanUp() { wxToolTip::RemoveToolTips() ; -#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 suppliedo ne might be even more unsafe (using any - // wxWindows 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 // One last chance for pending objects to be cleaned up wxTheApp->DeletePendingObjects(); - wxModule::CleanUpModules(); - - wxDeleteStockObjects() ; - - // Destroy all GDI lists, etc. - wxDeleteStockLists(); - - delete wxTheColourDatabase; - wxTheColourDatabase = NULL; - - wxBitmap::CleanUpHandlers(); - wxMacDestroyNotifierTable() ; - if (wxWinMacWindowList) { - delete wxWinMacWindowList ; - } - if (wxWinMacControlList) { - delete wxWinMacControlList ; - } - delete wxPendingEvents; - wxPendingEvents = NULL; -#if wxUSE_THREADS - delete wxPendingEventsLocker; - // There is still more cleanup code that will try to use this if not NULL. - wxPendingEventsLocker = NULL; - // If we don't do the following, we get an apparent memory leak. - ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker(); -#endif + delete wxWinMacWindowList ; + wxWinMacWindowList = NULL; - wxClassInfo::CleanUpClasses(); + delete wxWinMacControlList ; + wxWinMacControlList = NULL; #ifndef __DARWIN__ # if __option(profile) @@ -668,28 +614,6 @@ void wxApp::CleanUp() # endif #endif - 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(TRUE) > 0) - { - wxLogDebug(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 - #if defined(WXMAKINGDLL) && defined(__DARWIN__) // close shared library resources from here since we don't have // __wxterminate in Mach-O shared libraries @@ -705,6 +629,8 @@ void wxApp::CleanUp() #if 0 TerminateAE() ; #endif + + wxAppBase::CleanUp(); } //---------------------------------------------------------------------- @@ -1266,24 +1192,6 @@ bool wxApp::SendIdleEvents(wxWindow* win) return needMore ; } -void wxApp::DeletePendingObjects() -{ - wxNode *node = wxPendingDelete.GetFirst(); - while (node) - { - wxObject *obj = (wxObject *)node->GetData(); - - delete obj; - - if (wxPendingDelete.Member(obj)) - delete node; - - // Deleting one object may have deleted other pending - // objects, so start from beginning of list again. - node = wxPendingDelete.GetFirst(); - } -} - void wxApp::Exit() { wxApp::CleanUp(); diff --git a/src/mgl/app.cpp b/src/mgl/app.cpp index 1927ed7869..f21c6a862a 100644 --- a/src/mgl/app.cpp +++ b/src/mgl/app.cpp @@ -383,119 +383,41 @@ void wxApp::Dispatch() wxEventLoop::GetActive()->Dispatch(); } -void wxApp::DeletePendingObjects() +bool wxApp::Initialize(int argc, wxChar **argv) { - wxNode *node = wxPendingDelete.First(); - while (node) - { - wxObject *obj = (wxObject *)node->Data(); - - delete obj; + // must do it before calling wxAppBase::Initialize(), because fonts are + // needed by stock lists which are created there + wxTheFontsManager = new wxFontsManager; - if ( wxPendingDelete.Find(obj) ) - delete node; + if ( !wxAppBase::Initialize(argc, argv) ) + return false; - node = wxPendingDelete.First(); - } -} - -bool wxApp::Initialize() -{ if ( MGL_init(".", NULL) == 0 ) { wxLogError(_("Cannot initialize SciTech MGL!")); - return FALSE; - } - wxClassInfo::InitializeClasses(); + wxAppBase::CleanUp(); + + return false; + } #if wxUSE_INTL wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); #endif - // GL: I'm annoyed ... I don't know where to put this and I don't want to - // create a module for that as it's part of the core. -#if wxUSE_THREADS - wxPendingEvents = new wxList; - wxPendingEventsLocker = new wxCriticalSection; -#endif - - wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); - wxTheColourDatabase->Initialize(); - - // Can't do this in wxModule, because fonts are needed by stock lists - wxTheFontsManager = new wxFontsManager; - - wxInitializeStockLists(); - wxInitializeStockObjects(); - - wxModule::RegisterModules(); - if (!wxModule::InitializeModules()) return FALSE; - - return TRUE; + return true; } void wxApp::CleanUp() { -#if wxUSE_LOG - // 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 *oldlog = wxLog::SetActiveTarget(new wxLogStderr); - if ( oldlog ) - delete oldlog; -#endif // wxUSE_LOG - delete gs_rootWindow; - wxModule::CleanUpModules(); - - if (wxTheColourDatabase) - delete wxTheColourDatabase; - - wxTheColourDatabase = (wxColourDatabase*) NULL; - - wxDeleteStockObjects(); - wxDeleteStockLists(); - - delete wxTheApp; - wxTheApp = (wxApp*) NULL; - - - // GL: I'm annoyed ... I don't know where to put this and I don't want to - // create a module for that as it's part of the core. -#if wxUSE_THREADS - delete wxPendingEvents; - delete wxPendingEventsLocker; -#endif - - wxClassInfo::CleanUpClasses(); + wxAppBase::CleanUp(); - // Can't do this in wxModule, because fonts are needed by stock lists - // (do it after deleting wxTheApp and cleaning modules up, since somebody - // may be deleting fonts that lately) + // must do this after calling base class CleanUp() delete wxTheFontsManager; wxTheFontsManager = (wxFontsManager*) NULL; - // 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 - -#if wxUSE_LOG - // do this as the very last thing because everything else can log messages - wxLog::DontCreateOnDemand(); - - wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL ); - if (oldLog) - delete oldLog; -#endif // wxUSE_LOG - wxDestroyMGL_WM(); MGL_exit(); } diff --git a/src/motif/app.cpp b/src/motif/app.cpp index d7a0f97dbb..a2e569037c 100644 --- a/src/motif/app.cpp +++ b/src/motif/app.cpp @@ -86,77 +86,22 @@ END_EVENT_TABLE() } #endif // __WXDEBUG__ -bool wxApp::Initialize() +bool wxApp::Initialize(int argc, wxChar **argv) { - wxClassInfo::InitializeClasses(); - - // GL: I'm annoyed ... I don't know where to put this and I don't want to - // create a module for that as it's part of the core. -#if wxUSE_THREADS - wxPendingEventsLocker = new wxCriticalSection(); -#endif - - wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); - wxTheColourDatabase->Initialize(); - - wxInitializeStockLists(); - wxInitializeStockObjects(); + if ( !wxAppBase::Initialize(argc, argv) ) + return false; wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER); - wxModule::RegisterModules(); - if (!wxModule::InitializeModules()) return FALSE; - - return TRUE; + return true; } void wxApp::CleanUp() { - wxModule::CleanUpModules(); - - wxDeleteStockObjects() ; - - // Destroy all GDI lists, etc. - - wxDeleteStockLists(); - - delete wxTheColourDatabase; - wxTheColourDatabase = NULL; - - wxClassInfo::CleanUpClasses(); - - delete wxTheApp; - wxTheApp = NULL; - delete wxWidgetHashTable; wxWidgetHashTable = NULL; - // GL: I'm annoyed ... I don't know where to put this and I don't want to - // create a module for that as it's part of the core. -#if wxUSE_THREADS - delete wxPendingEvents; - wxPendingEvents = NULL; - delete wxPendingEventsLocker; - wxPendingEventsLocker = NULL; -#endif - -#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) - { - wxLogDebug("There were memory leaks.\n"); - wxDebugContext::Dump(); - wxDebugContext::PrintStatistics(); - } -#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); + wxAppBase::CleanUp(); } void wxApp::Exit() @@ -447,24 +392,6 @@ bool wxApp::SendIdleEvents(wxWindow* win) return needMore ; } -void wxApp::DeletePendingObjects() -{ - wxList::Node *node = wxPendingDelete.GetFirst(); - while (node) - { - wxObject *obj = node->GetData(); - - delete obj; - - if (wxPendingDelete.Member(obj)) - delete node; - - // Deleting one object may have deleted other pending - // objects, so start from beginning of list again. - node = wxPendingDelete.GetFirst(); - } -} - static char *fallbackResources[] = { "*menuBar.marginHeight: 0", "*menuBar.shadowThickness: 1", diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 1b2e4f96ba..d0adf0525b 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -49,7 +49,6 @@ #endif #include "wx/apptrait.h" -#include "wx/cmdline.h" #include "wx/filename.h" #include "wx/module.h" @@ -89,10 +88,6 @@ #include #endif -#ifndef __WXMICROWIN__ -#include "wx/msw/msvcrt.h" -#endif - // ---------------------------------------------------------------------------- // conditional compilation // ---------------------------------------------------------------------------- @@ -141,31 +136,13 @@ const wxChar *wxMDIFrameClassNameNoRedraw = wxT("wxMDIFrameClassNR"); const wxChar *wxMDIChildFrameClassName = wxT("wxMDIChildFrameClass"); const wxChar *wxMDIChildFrameClassNameNoRedraw = wxT("wxMDIChildFrameClassNR"); -HICON wxSTD_FRAME_ICON = (HICON) NULL; -HICON wxSTD_MDICHILDFRAME_ICON = (HICON) NULL; -HICON wxSTD_MDIPARENTFRAME_ICON = (HICON) NULL; - -HICON wxDEFAULT_FRAME_ICON = (HICON) NULL; -HICON wxDEFAULT_MDICHILDFRAME_ICON = (HICON) NULL; -HICON wxDEFAULT_MDIPARENTFRAME_ICON = (HICON) NULL; - HBRUSH wxDisableButtonBrush = (HBRUSH) 0; -LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM); +// ---------------------------------------------------------------------------- +// private functions +// ---------------------------------------------------------------------------- -// FIXME wxUSE_ON_FATAL_EXCEPTION is only supported for VC++ now because it -// needs compiler support for Win32 SEH. Others (especially Borland) -// probably have it too, but I'm not sure about how it works -// JACS: get 'Cannot use __try in functions that require unwinding -// in Unicode mode, so disabling. -#if !defined(__VISUALC__) || defined(__WIN16__) || defined(UNICODE) - #undef wxUSE_ON_FATAL_EXCEPTION - #define wxUSE_ON_FATAL_EXCEPTION 0 -#endif // VC++ - -#if wxUSE_ON_FATAL_EXCEPTION - static bool gs_handleExceptions = FALSE; -#endif +LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM); // =========================================================================== // wxGUIAppTraits implementation @@ -252,6 +229,8 @@ bool wxGUIAppTraits::DoMessageFromThreadWait() // wxApp implementation // =========================================================================== +int wxApp::m_nCmdShow = SW_SHOWNORMAL; + // --------------------------------------------------------------------------- // wxWin macros // --------------------------------------------------------------------------- @@ -264,9 +243,29 @@ BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession) END_EVENT_TABLE() +// class to ensure that wxAppBase::CleanUp() is called if our Initialize() +// fails +class wxCallBaseCleanup +{ +public: + wxCallBaseCleanup(wxApp *app) : m_app(app) { } + ~wxCallBaseCleanup() { if ( m_app ) m_app->wxAppBase::CleanUp(); } + + void Dismiss() { m_app = NULL; } + +private: + wxApp *m_app; +}; + //// Initialize -bool wxApp::Initialize() +bool wxApp::Initialize(int argc, wxChar **argv) { + if ( !wxAppBase::Initialize(argc, argv) ) + return false; + + // ensure that base cleanup is done if we return too early + wxCallBaseCleanup callBaseCleanup(this); + // the first thing to do is to check if we're trying to run an Unicode // program under Win9x w/o MSLU emulation layer - if so, abort right now // as it has no chance to work @@ -290,20 +289,6 @@ bool wxApp::Initialize() wxBuffer = new wxChar[1500]; // FIXME - wxClassInfo::InitializeClasses(); - -#if wxUSE_THREADS - wxPendingEventsLocker = new wxCriticalSection; -#endif - - wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); - wxTheColourDatabase->Initialize(); - - wxInitializeStockLists(); - wxInitializeStockObjects(); - - wxBitmap::InitStandardHandlers(); - #if defined(__WIN95__) && !defined(__WXMICROWIN__) InitCommonControls(); #endif // __WIN95__ @@ -332,17 +317,6 @@ bool wxApp::Initialize() Ctl3dAutoSubclass(wxhInstance); #endif // wxUSE_CTL3D - // VZ: these icons are not in wx.rc anyhow (but should they?)! -#if 0 - wxSTD_FRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_FRAME")); - wxSTD_MDIPARENTFRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_MDIPARENTFRAME")); - wxSTD_MDICHILDFRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_MDICHILDFRAME")); - - wxDEFAULT_FRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_FRAME")); - wxDEFAULT_MDIPARENTFRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_MDIPARENTFRAME")); - wxDEFAULT_MDICHILDFRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_MDICHILDFRAME")); -#endif // 0 - RegisterWindowClasses(); #ifndef __WXMICROWIN__ @@ -377,10 +351,9 @@ bool wxApp::Initialize() wxSetKeyboardHook(TRUE); #endif - wxModule::RegisterModules(); - if (!wxModule::InitializeModules()) - return FALSE; - return TRUE; + callBaseCleanup.Dismiss(); + + return true; } // --------------------------------------------------------------------------- @@ -525,80 +498,11 @@ bool wxApp::UnregisterWindowClasses() return retval; } -// --------------------------------------------------------------------------- -// Convert Windows to argc, argv style -// --------------------------------------------------------------------------- - -void wxApp::ConvertToStandardCommandArgs(const char* lpCmdLine) -{ - // break the command line in words - wxArrayString args = - wxCmdLineParser::ConvertStringToArgs(wxConvertMB2WX(lpCmdLine)); - - // +1 here for the program name - argc = args.GetCount() + 1; - - // and +1 here for the terminating NULL - argv = new wxChar *[argc + 1]; - - argv[0] = new wxChar[260]; // 260 is MAX_PATH value from windef.h - ::GetModuleFileName(wxhInstance, argv[0], 260); - - // also set the app name from argv[0] - wxString name; - wxFileName::SplitPath(argv[0], NULL, &name, NULL); - - // but don't override the name already set by the user code, if any - if ( GetAppName().empty() ) - SetAppName(name); - - // copy all the other arguments to wxApp::argv[] - for ( int i = 1; i < argc; i++ ) - { - argv[i] = copystring(args[i - 1]); - } - - // argv[] must be NULL-terminated - argv[argc] = NULL; -} - -//// Cleans up any wxWindows internal structures left lying around - void wxApp::CleanUp() { - //// COMMON CLEANUP - -#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 suppliedo ne might be even more unsafe (using any - // wxWindows 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 - - // One last chance for pending objects to be cleaned up - wxTheApp->DeletePendingObjects(); - - wxModule::CleanUpModules(); - - wxDeleteStockObjects(); - - // Destroy all GDI lists, etc. - wxDeleteStockLists(); - - delete wxTheColourDatabase; - wxTheColourDatabase = NULL; - - wxBitmap::CleanUpHandlers(); - delete[] wxBuffer; wxBuffer = NULL; - //// WINDOWS-SPECIFIC CLEANUP - #ifndef __WXMICROWIN__ wxSetKeyboardHook(FALSE); #endif @@ -607,20 +511,6 @@ void wxApp::CleanUp() wxCleanUpPenWin(); #endif - if (wxSTD_FRAME_ICON) - DestroyIcon(wxSTD_FRAME_ICON); - if (wxSTD_MDICHILDFRAME_ICON) - DestroyIcon(wxSTD_MDICHILDFRAME_ICON); - if (wxSTD_MDIPARENTFRAME_ICON) - DestroyIcon(wxSTD_MDIPARENTFRAME_ICON); - - if (wxDEFAULT_FRAME_ICON) - DestroyIcon(wxDEFAULT_FRAME_ICON); - if (wxDEFAULT_MDICHILDFRAME_ICON) - DestroyIcon(wxDEFAULT_MDICHILDFRAME_ICON); - if (wxDEFAULT_MDIPARENTFRAME_ICON) - DestroyIcon(wxDEFAULT_MDIPARENTFRAME_ICON); - if ( wxDisableButtonBrush ) ::DeleteObject( wxDisableButtonBrush ); @@ -628,275 +518,44 @@ void wxApp::CleanUp() ::OleUninitialize(); #endif -#ifdef WXMAKINGDLL // for an EXE the classes are unregistered when it terminates but DLL may // be loaded several times (load/unload/load) into the same process in // which case the registration will fail after the first time if we don't // unregister the classes now UnregisterWindowClasses(); -#endif // WXMAKINGDLL #if wxUSE_CTL3D Ctl3dUnregister(wxhInstance); #endif delete wxWinHandleHash; - wxWinHandleHash = NULL; // Set to null in case anything later tries to ref it. - - delete wxPendingEvents; - wxPendingEvents = NULL; // Set to null because wxAppBase::wxEvtHandler is destroyed later. - -#if wxUSE_THREADS - delete wxPendingEventsLocker; - wxPendingEventsLocker = NULL; // Set to null because wxAppBase::wxEvtHandler is destroyed later. - // If we don't do the following, we get an apparent memory leak -#if wxUSE_VALIDATORS - ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker(); -#endif // wxUSE_VALIDATORS -#endif // wxUSE_THREADS - - 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(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() -{ - return wxTheApp->OnInitGui(); -} - -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++ + wxWinHandleHash = NULL; -//---------------------------------------------------------------------- -// 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) -#ifndef __WXMICROWIN__ - wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF); -#endif - -#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*) (*wxApp::GetInitializerFunction()) (); - } - - wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") ); - - // save the WinMain() parameters - if (lpCmdLine) // MicroWindows passes NULL - wxTheApp->ConvertToStandardCommandArgs(lpCmdLine); - wxTheApp->m_nCmdShow = nCmdShow; - - // 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__ -#if wxUSE_LOG - wxLog::SetTimestamp(NULL); -#endif // wxUSE_LOG -#endif // __VISUALC__ - - // init the app - int retValue = wxEntryInitGui() && wxTheApp->OnInit() ? 0 : -1; - - if ( retValue == 0 ) - { - if ( enterLoop ) - { - // run the main loop - wxTheApp->OnRun(); - } - else - { - // we want to initialize, but not run or exit immediately. - return 1; - } - } - //else: app initialization failed, so we skipped OnRun() - - wxWindow *topWindow = wxTheApp->GetTopWindow(); - if ( topWindow ) - { - // Forcibly delete the window. - if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) || - topWindow->IsKindOf(CLASSINFO(wxDialog)) ) - { - topWindow->Close(TRUE); - wxTheApp->DeletePendingObjects(); - } - else - { - delete topWindow; - wxTheApp->SetTopWindow(NULL); - } - } - - retValue = wxTheApp->OnExit(); - - wxEntryCleanup(); - - return retValue; - -#if wxUSE_ON_FATAL_EXCEPTION - } - __except ( gs_handleExceptions ? EXCEPTION_EXECUTE_HANDLER - : EXCEPTION_CONTINUE_SEARCH ) { - if ( wxTheApp ) - { - // give the user a chance to do something special about this - wxTheApp->OnFatalException(); - } - - ::ExitProcess(3); // the same exit code as abort() - - // NOTREACHED - } -#endif // wxUSE_ON_FATAL_EXCEPTION + wxAppBase::CleanUp(); } -// restore warning state -#ifdef __VISUALC__ - #pragma warning(default: 4715) // not all control paths return a value -#endif // Visual C++ - -#else /* _WINDLL */ - -//---------------------------------------------------------------------- -// Entry point for wxWindows + the App in a DLL -//---------------------------------------------------------------------- - -int wxEntry(WXHINSTANCE hInstance) -{ - wxhInstance = (HINSTANCE) hInstance; - wxEntryStart(0, 0); - - // 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. - if (!wxTheApp) - { - wxCHECK_MSG( wxApp::GetInitializerFunction(), 0, - "No initializer - use IMPLEMENT_APP macro." ); - - wxTheApp = (* wxApp::GetInitializerFunction()) (); - } - - wxCHECK_MSG( wxTheApp, 0, "You have to define an instance of wxApp!" ); - - wxTheApp->argc = 0; - wxTheApp->argv = NULL; - - wxEntryInitGui(); - - wxTheApp->OnInit(); - - wxWindow *topWindow = wxTheApp->GetTopWindow(); - if ( topWindow && topWindow->GetHWND()) - { - topWindow->Show(TRUE); - } - - return 1; -} -#endif // _WINDLL - -//// Static member initialization +// ---------------------------------------------------------------------------- +// wxApp ctor/dtor +// ---------------------------------------------------------------------------- wxApp::wxApp() { - argc = 0; - argv = NULL; m_printMode = wxPRINT_WINDOWS; - m_auto3D = TRUE; } wxApp::~wxApp() { - // Delete command-line args - int i; - for (i = 0; i < argc; i++) + // our cmd line arguments are allocated inside wxEntry(HINSTANCE), they + // don't come from main(), so we have to free them + + while ( argc ) { - delete[] argv[i]; + // m_argv elements were allocated by wxStrdup() + free(argv[--argc]); } - delete[] argv; + + // but m_argv itself -- using new[] + delete [] argv; } bool wxApp::Initialized() @@ -1242,24 +901,6 @@ void wxApp::WakeUpIdle() } } -void wxApp::DeletePendingObjects() -{ - wxNode *node = wxPendingDelete.GetFirst(); - while (node) - { - wxObject *obj = node->GetData(); - - delete obj; - - if (wxPendingDelete.Member(obj)) - delete node; - - // Deleting one object may have deleted other pending - // objects, so start from beginning of list again. - node = wxPendingDelete.GetFirst(); - } -} - void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event)) { if (GetTopWindow()) @@ -1443,25 +1084,3 @@ bool wxApp::Yield(bool onlyIfNeeded) return TRUE; } -bool wxHandleFatalExceptions(bool doit) -{ -#if wxUSE_ON_FATAL_EXCEPTION - // assume this can only be called from the main thread - gs_handleExceptions = doit; - - return TRUE; -#else - wxFAIL_MSG(_T("set wxUSE_ON_FATAL_EXCEPTION to 1 to use this function")); - - (void)doit; - return FALSE; -#endif -} - -//----------------------------------------------------------------------------- - -// For some reason, with MSVC++ 1.5, WinMain isn't linked in properly -// if in a separate file. So include it here to ensure it's linked. -#if (defined(__VISUALC__) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !defined(__WINE__) && !defined(WXMAKINGDLL)) -#include "main.cpp" -#endif diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 4ed0d984d6..9c9dc1d35f 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -506,8 +506,8 @@ void wxFrame::IconizeChildFrames(bool bIconize) WXHICON wxFrame::GetDefaultIcon() const { - return (WXHICON)(wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON - : wxDEFAULT_FRAME_ICON); + // we don't have any standard icons (any more) + return (WXHICON)0; } // =========================================================================== diff --git a/src/msw/main.cpp b/src/msw/main.cpp index 94299293e1..20a274a5dc 100644 --- a/src/msw/main.cpp +++ b/src/msw/main.cpp @@ -30,6 +30,7 @@ #include "wx/event.h" #include "wx/app.h" +#include "wx/cmdline.h" #include "wx/msw/private.h" @@ -48,6 +49,8 @@ #define HINSTANCE HANDLE #endif +#if wxUSE_GUI + // ---------------------------------------------------------------------------- // function prototypes // ---------------------------------------------------------------------------- @@ -55,13 +58,35 @@ // from src/msw/app.cpp extern void WXDLLEXPORT wxEntryCleanup(); +static wxChar **ConvertToStandardCommandArgs(const wxChar *p, int& argc); + // ============================================================================ // implementation: various entry points // ============================================================================ +// ---------------------------------------------------------------------------- +// Windows-specific wxEntry +// ---------------------------------------------------------------------------- + +int wxEntry(WXHINSTANCE hInstance, + WXHINSTANCE WXUNUSED(hPrevInstance), + char *pCmdLine, + int nCmdShow) +{ + // remember the parameters Windows gave us + wxSetInstance((HINSTANCE)hInstance); + wxApp::m_nCmdShow = nCmdShow; + + // parse the command line + int argc; + wxChar **argv = ConvertToStandardCommandArgs(wxConvertMB2WX(pCmdLine), argc); + + return wxEntry(argc, argv); +} + // May wish not to have a DllMain or WinMain, e.g. if we're programming // a Netscape plugin or if we're writing a console application -#if wxUSE_GUI && !defined(NOMAIN) +#if !defined(NOMAIN) extern "C" { @@ -104,10 +129,8 @@ DllMain(HANDLE hModule, DWORD fdwReason, LPVOID WXUNUSED(lpReserved)) return wxEntry((WXHINSTANCE) hModule); case DLL_PROCESS_DETACH: - if ( wxTheApp ) - wxTheApp->OnExit(); - wxEntryCleanup(); - break; + wxEntryCleanup(); + break; } #else (void)hModule; @@ -123,6 +146,42 @@ DllMain(HANDLE hModule, DWORD fdwReason, LPVOID WXUNUSED(lpReserved)) #endif // !NOMAIN +// --------------------------------------------------------------------------- +// Convert Windows to argc, argv style +// --------------------------------------------------------------------------- + +wxChar **ConvertToStandardCommandArgs(const wxChar *p, int& argc) +{ + // break the command line in words + wxArrayString args; + if ( p ) + { + args = wxCmdLineParser::ConvertStringToArgs(p); + } + + // +1 here for the program name + argc = args.GetCount() + 1; + + // and +1 here for the terminating NULL + wxChar **argv = new wxChar *[argc + 1]; + + argv[0] = new wxChar[MAX_PATH]; + ::GetModuleFileName(wxhInstance, argv[0], MAX_PATH); + + // copy all the other arguments to wxApp::argv[] + for ( int i = 1; i < argc; i++ ) + { + argv[i] = wxStrdup(args[i - 1]); + } + + // argv[] must be NULL-terminated + argv[argc] = NULL; + + return argv; +} + +#endif // wxUSE_GUI + // ---------------------------------------------------------------------------- // global HINSTANCE // ---------------------------------------------------------------------------- diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index a00557187d..6089dcde74 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -342,8 +342,8 @@ void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event) WXHICON wxMDIParentFrame::GetDefaultIcon() const { - return (WXHICON)(wxSTD_MDIPARENTFRAME_ICON ? wxSTD_MDIPARENTFRAME_ICON - : wxDEFAULT_MDIPARENTFRAME_ICON); + // we don't have any standard icons (any more) + return (WXHICON)0; } // --------------------------------------------------------------------------- @@ -811,8 +811,8 @@ void wxMDIChildFrame::InternalSetMenuBar() WXHICON wxMDIChildFrame::GetDefaultIcon() const { - return (WXHICON)(wxSTD_MDICHILDFRAME_ICON ? wxSTD_MDICHILDFRAME_ICON - : wxDEFAULT_MDICHILDFRAME_ICON); + // we don't have any standard icons (any more) + return (WXHICON)0; } // --------------------------------------------------------------------------- diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 770ea11fe2..aff561ff85 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -89,6 +89,14 @@ #endif #endif +// ---------------------------------------------------------------------------- +// module globals +// ---------------------------------------------------------------------------- + +#if wxUSE_ON_FATAL_EXCEPTION + static bool gs_handleExceptions = FALSE; +#endif + // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -1191,3 +1199,40 @@ extern long wxCharsetToCodepage(const wxChar *name) #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP +// ---------------------------------------------------------------------------- +// wxApp::OnFatalException() support +// ---------------------------------------------------------------------------- + +bool wxHandleFatalExceptions(bool doit) +{ +#if wxUSE_ON_FATAL_EXCEPTION + // assume this can only be called from the main thread + gs_handleExceptions = doit; + + return TRUE; +#else + wxFAIL_MSG(_T("set wxUSE_ON_FATAL_EXCEPTION to 1 to use this function")); + + (void)doit; + return FALSE; +#endif +} + +#if wxUSE_ON_FATAL_EXCEPTION + +extern unsigned long wxGlobalSEHandler() +{ + if ( gs_handleExceptions && wxTheApp ) + { + // give the user a chance to do something special about this + wxTheApp->OnFatalException(); + + // this will execute our handler and terminate the process + return EXCEPTION_EXECUTE_HANDLER; + } + + return EXCEPTION_CONTINUE_SEARCH; +} + +#endif // wxUSE_ON_FATAL_EXCEPTION + diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 45b1156215..21a1c344cd 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1035,7 +1035,7 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const // is a more neutral term, we don't necessarily get a sunken effect in // Windows XP. Instead we get the appropriate style for the theme. - if (border == wxBORDER_DEFAULT && wxTheApp->GetAuto3D() && + if (border == wxBORDER_DEFAULT && IsKindOf(CLASSINFO(wxControl)) && GetParent() && ((GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) != wxUSER_COLOURS)) diff --git a/src/os2/app.cpp b/src/os2/app.cpp index 5db7a6bcfc..bde40f8e18 100644 --- a/src/os2/app.cpp +++ b/src/os2/app.cpp @@ -226,10 +226,11 @@ void wxApp::HandleSockets() // // Initialize // -bool wxApp::Initialize( - HAB vHab -) +bool wxApp::Initialize(int argc, wxChar **argv) { + if ( !wxAppBase::Initialize(argc, argv) ) + return false; + #if defined(wxUSE_CONSOLEDEBUG) #if wxUSE_CONSOLEDEBUG /***********************************************/ @@ -252,31 +253,20 @@ bool wxApp::Initialize( #endif //wxUSE_CONSOLEDEBUG #endif - wxBuffer = new wxChar[1500]; // FIXME; why? - - wxClassInfo::InitializeClasses(); - -#if wxUSE_THREADS - wxPendingEventsLocker = new wxCriticalSection; -#endif - - wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); - wxTheColourDatabase->Initialize(); - - wxInitializeStockLists(); - wxInitializeStockObjects(); - - wxBitmap::InitStandardHandlers(); - // // OS2 has to have an anchorblock // - vHab = WinInitialize(0); + vHabmain = WinInitialize(0); + + if (!vHabmain) + { + // TODO: at least give some error message here... + wxAppBase::CleanUp(); - if (!vHab) return FALSE; - else - vHabmain = vHab; + } + + wxBuffer = new wxChar[1500]; // FIXME; why? // Some people may wish to use this, but // probably it shouldn't be here by default. @@ -295,10 +285,8 @@ bool wxApp::Initialize( // wxSetKeyboardHook(TRUE); - wxModule::RegisterModules(); - if (!wxModule::InitializeModules()) - return FALSE; RegisterWindowClasses(vHab); + return TRUE; } // end of wxApp::Initialize @@ -437,45 +425,6 @@ bool wxApp::RegisterWindowClasses( // void wxApp::CleanUp() { - // - // COMMON CLEANUP - // - -#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 suppliedo ne might be even more unsafe (using any - // wxWindows 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 - - // - // One last chance for pending objects to be cleaned up - // - wxTheApp->DeletePendingObjects(); - - wxModule::CleanUpModules(); - - wxDeleteStockObjects(); - - // - // Destroy all GDI lists, etc. - // - wxDeleteStockLists(); - - delete wxTheColourDatabase; - wxTheColourDatabase = NULL; - - wxBitmap::CleanUpHandlers(); - delete[] wxBuffer; wxBuffer = NULL; @@ -514,33 +463,11 @@ void wxApp::CleanUp() ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker(); #endif - wxClassInfo::CleanUpClasses(); - // Delete Message queue if (wxTheApp->m_hMq) ::WinDestroyMsgQueue(wxTheApp->m_hMq); - 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(TRUE) > 0) - { - wxLogDebug(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 + wxAppBase::CleanUp(); } // end of wxApp::CleanUp //---------------------------------------------------------------------- @@ -1051,27 +978,6 @@ bool wxApp::SendIdleEvents( return bNeedMore; } // end of wxApp::SendIdleEvents -void wxApp::DeletePendingObjects() -{ - wxNode* pNode = wxPendingDelete.First(); - - while (pNode) - { - wxObject* pObj = (wxObject *)pNode->Data(); - - delete pObj; - - if (wxPendingDelete.Member(pObj)) - delete pNode; - - // - // Deleting one object may have deleted other pending - // objects, so start from beginning of list again. - // - pNode = wxPendingDelete.First(); - } -} // end of wxApp::DeletePendingObjects - void wxApp::OnEndSession( wxCloseEvent& WXUNUSED(rEvent)) { diff --git a/src/wxBase.dsp b/src/wxBase.dsp index db4d2606ab..96a16adcf2 100644 --- a/src/wxBase.dsp +++ b/src/wxBase.dsp @@ -2,8 +2,8 @@ # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** -# TARGTYPE "Win32 (x86) Static Library" 0x0104 # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 +# TARGTYPE "Win32 (x86) Static Library" 0x0104 CFG=wxBase - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, @@ -32,8 +32,6 @@ CFG=wxBase - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe !IF "$(CFG)" == "wxBase - Win32 Release Unicode DLL" @@ -48,10 +46,13 @@ RSC=rc.exe # PROP Intermediate_Dir "../BaseReleaseUnicodeDll" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "WXBASEDLL_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W4 /O2 /I "../lib/basedllu" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MD /W4 /O2 /I "../lib/basedllu" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c +MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +RSC=rc.exe # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /i "../include" /d "NDEBUG" BSC32=bscmake.exe @@ -59,7 +60,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../lib/wxbase250u.dll" -# ADD LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib ../lib/zlib.lib ../lib/regex.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250u.dll" +# ADD LINK32 ../lib/zlib.lib ../lib/regex.lib kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib gdi32.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250u.dll" !ELSEIF "$(CFG)" == "wxBase - Win32 Debug Unicode DLL" @@ -74,18 +75,22 @@ LINK32=link.exe # PROP Intermediate_Dir "../BaseDebugUnicodeDll" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "WXBASEDLL_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/basedllud" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/basedllud" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c +MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +RSC=rc.exe # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /i "../include" /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /out:"../lib/wxbase250ud.dll" -# ADD LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib ../lib/zlibd.lib ../lib/regexd.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250ud.dll" +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../lib/wxbase250ud.dll" /pdbtype:sept +# ADD LINK32 ../lib/zlibd.lib ../lib/regexd.lib kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib gdi32.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250ud.dll" + !ELSEIF "$(CFG)" == "wxBase - Win32 Release Unicode" # PROP BASE Use_MFC 0 @@ -98,8 +103,10 @@ LINK32=link.exe # PROP Output_Dir "..\lib" # PROP Intermediate_Dir "..\BaseReleaseUnicode" # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W4 /O2 /I "../lib/baseu" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MD /W4 /O2 /I "../lib/baseu" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c +RSC=rc.exe # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe @@ -121,13 +128,15 @@ LIB32=link.exe -lib # PROP Output_Dir "..\lib" # PROP Intermediate_Dir "..\BaseDebugUnicode" # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/baseud" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D wxUSE_GUI=0 /D "WIN32" /D "__WXDEBUG__" /D WINVER=0x400 /D "_UNICODE" /D "UNICODE" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/baseud" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D "__WXDEBUG__" /D "_UNICODE" /D "UNICODE" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c +RSC=rc.exe # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe # ADD BASE BSC32 /nologo -# ADD BSC32 /nologo /o"../lib/wxbase.bsc" +# ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib\wxbaseud.lib" @@ -145,10 +154,13 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "../BaseReleaseDll" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "WXBASEDLL_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W4 /O2 /I "../lib/basedll" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /D "WXMAKINGDLL" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MD /W4 /O2 /I "../lib/basedll" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D "WXMAKINGDLL" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c +MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +RSC=rc.exe # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /i "../include" /d "NDEBUG" BSC32=bscmake.exe @@ -156,7 +168,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../lib/wxbase250.dll" -# ADD LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib ../lib/zlib.lib ../lib/regex.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250.dll" +# ADD LINK32 ../lib/zlib.lib ../lib/regex.lib kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib gdi32.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250.dll" !ELSEIF "$(CFG)" == "wxBase - Win32 Debug DLL" @@ -171,18 +183,21 @@ LINK32=link.exe # PROP Intermediate_Dir "../BaseDebugDll" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "WXBASEDLL_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/basedlld" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /D "WXMAKINGDLL" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/basedlld" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D "WXMAKINGDLL" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c +MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +RSC=rc.exe # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /i "../include" /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /out:"../lib/wxbase250d.dll" -# ADD LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib ../lib/zlibd.lib ../lib/regexd.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250d.dll" +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../lib/wxbase250d.dll" /pdbtype:sept +# ADD LINK32 ../lib/zlibd.lib ../lib/regexd.lib kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib gdi32.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxbase250d.dll" !ELSEIF "$(CFG)" == "wxBase - Win32 Release" @@ -196,8 +211,10 @@ LINK32=link.exe # PROP Output_Dir "..\lib" # PROP Intermediate_Dir "..\BaseRelease" # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W4 /O2 /I "../lib/base" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MD /W4 /O2 /I "../lib/base" /I "../include" /I "./regex" /I "./zlib" /D "NDEBUG" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c +RSC=rc.exe # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe @@ -205,7 +222,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\lib\wxbase.lib" +# ADD LIB32 /nologo !ELSEIF "$(CFG)" == "wxBase - Win32 Debug" @@ -219,13 +236,15 @@ LIB32=link.exe -lib # PROP Output_Dir "..\lib" # PROP Intermediate_Dir "..\BaseDebug" # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/based" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D wxUSE_GUI=0 /D "WIN32" /D "__WXDEBUG__" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/based" /I "../include" /I "./regex" /I "./zlib" /D "_DEBUG" /D "__WXDEBUG__" /D wxUSE_BASE=1 /D wxUSE_GUI=0 /D "WIN32" /D WINVER=0x400 /Yu"wx/wxprec.h" /FD /c +RSC=rc.exe # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe # ADD BASE BSC32 /nologo -# ADD BSC32 /nologo /o"../lib/wxbase.bsc" +# ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib\wxbased.lib" @@ -242,7 +261,6 @@ LIB32=link.exe -lib # Name "wxBase - Win32 Debug DLL" # Name "wxBase - Win32 Release" # Name "wxBase - Win32 Debug" - # Begin Group "Common Files" # PROP Default_Filter "" @@ -304,6 +322,11 @@ SOURCE=.\common\event.cpp # End Source File # Begin Source File +SOURCE=.\common\extended.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + SOURCE=.\common\ffile.cpp # End Source File # Begin Source File @@ -360,6 +383,10 @@ SOURCE=.\common\http.cpp # End Source File # Begin Source File +SOURCE=.\common\init.cpp +# End Source File +# Begin Source File + SOURCE=.\common\intl.cpp # End Source File # Begin Source File @@ -472,6 +499,11 @@ SOURCE=.\common\txtstrm.cpp # End Source File # Begin Source File +SOURCE=.\common\unzip.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + SOURCE=.\common\url.cpp # End Source File # Begin Source File @@ -498,26 +530,22 @@ SOURCE=.\common\zipstrm.cpp SOURCE=.\common\zstream.cpp # End Source File +# End Group +# Begin Group "MSW Files" + +# PROP Default_Filter "" # Begin Source File -SOURCE=.\common\init.cpp +SOURCE=.\msw\basemsw.cpp # End Source File - # Begin Source File -SOURCE=.\common\extended.c -# SUBTRACT CPP /YX /Yc /Yu +SOURCE=.\msw\dde.cpp # End Source File # Begin Source File -SOURCE=.\common\unzip.c -# SUBTRACT CPP /YX /Yc /Yu +SOURCE=.\msw\dir.cpp # End Source File - -# End Group -# Begin Group "MSW Files" - -# PROP Default_Filter "" # Begin Source File SOURCE=.\msw\dummy.cpp @@ -525,15 +553,13 @@ SOURCE=.\msw\dummy.cpp # End Source File # Begin Source File -SOURCE=.\msw\basemsw.cpp -# End Source File -# Begin Source File - -SOURCE=.\msw\dde.cpp +SOURCE=.\msw\gsocket.c +# SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File -SOURCE=.\msw\dir.cpp +SOURCE=.\msw\gsockmsw.c +# SUBTRACT CPP /YX /Yc /Yu # End Source File # Begin Source File @@ -575,18 +601,6 @@ SOURCE=.\msw\utilsexc.cpp SOURCE=.\msw\volume.cpp # End Source File - -# Begin Source File - -SOURCE=.\msw\gsocket.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=.\msw\gsockmsw.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File - # End Group # Begin Group "Headers" @@ -597,7 +611,9 @@ SOURCE=.\msw\gsockmsw.c # Begin Source File SOURCE=..\include\wx\msw\setup.h + !IF "$(CFG)" == "wxBase - Win32 Release Unicode DLL" + # Begin Custom Build - Copying $(InputPath) to $(TargetDir) InputPath=..\include\wx\msw\setup.h @@ -605,14 +621,19 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\basedllu\wx\setup.h # End Custom Build + !ELSEIF "$(CFG)" == "wxBase - Win32 Debug Unicode DLL" + # Begin Custom Build - Copying $(InputPath) to $(TargetDir) InputPath=..\include\wx\msw\setup.h "../lib/basedllud/wx/setup.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" copy "$(InputPath)" ..\lib\basedllud\wx\setup.h + # End Custom Build + !ELSEIF "$(CFG)" == "wxBase - Win32 Release Unicode" + # Begin Custom Build - Copying $(InputPath) to $(TargetDir) InputPath=..\include\wx\msw\setup.h @@ -620,7 +641,9 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\baseu\wx\setup.h # End Custom Build + !ELSEIF "$(CFG)" == "wxBase - Win32 Debug Unicode" + # Begin Custom Build - Copying $(InputPath) to $(TargetDir) InputPath=..\include\wx\msw\setup.h @@ -628,7 +651,9 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\baseud\wx\setup.h # End Custom Build + !ELSEIF "$(CFG)" == "wxBase - Win32 Release DLL" + # Begin Custom Build - Copying $(InputPath) to $(TargetDir) InputPath=..\include\wx\msw\setup.h @@ -636,14 +661,19 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\basedll\wx\setup.h # End Custom Build + !ELSEIF "$(CFG)" == "wxBase - Win32 Debug DLL" + # Begin Custom Build - Copying $(InputPath) to $(TargetDir) InputPath=..\include\wx\msw\setup.h "../lib/basedlld/wx/setup.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" copy "$(InputPath)" ..\lib\basedlld\wx\setup.h + # End Custom Build + !ELSEIF "$(CFG)" == "wxBase - Win32 Release" + # Begin Custom Build - Copying $(InputPath) to $(TargetDir) InputPath=..\include\wx\msw\setup.h @@ -651,7 +681,9 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\base\wx\setup.h # End Custom Build + !ELSEIF "$(CFG)" == "wxBase - Win32 Debug" + # Begin Custom Build - Copying $(InputPath) to $(TargetDir) InputPath=..\include\wx\msw\setup.h @@ -659,6 +691,7 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\based\wx\setup.h # End Custom Build + !ENDIF # End Source File @@ -1022,7 +1055,6 @@ SOURCE=..\include\wx\zipstrm.h SOURCE=..\include\wx\zstream.h # End Source File - # End Group # Begin Group "MSW" @@ -1051,7 +1083,6 @@ SOURCE=..\include\wx\msw\mimetype.h SOURCE=..\include\wx\msw\winundef.h # End Source File - # End Group # End Group # End Target diff --git a/src/wxMSW.dsp b/src/wxMSW.dsp index 97a1ef024f..d51eda2bb6 100644 --- a/src/wxMSW.dsp +++ b/src/wxMSW.dsp @@ -9,12 +9,12 @@ CFG=wxWindows - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE -!MESSAGE NMAKE /f "wxWindows.mak". +!MESSAGE NMAKE /f "wxMSW.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE -!MESSAGE NMAKE /f "wxWindows.mak" CFG="wxWindows - Win32 Debug" +!MESSAGE NMAKE /f "wxMSW.mak" CFG="wxWindows - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE @@ -197,7 +197,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /out:"../lib/wxmsw250d.dll" /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib odbc32.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxmsw250d.dll" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib odbc32.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib ../lib/wxbase250d.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxmsw250d.dll" !ELSEIF "$(CFG)" == "wxWindows - Win32 Release" @@ -222,7 +222,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\lib\wxmsw.lib" +# ADD LIB32 /nologo !ELSEIF "$(CFG)" == "wxWindows - Win32 Debug" diff --git a/src/wxWindows.dsp b/src/wxWindows.dsp index 3c1b42fccc..9b0568ed5f 100644 --- a/src/wxWindows.dsp +++ b/src/wxWindows.dsp @@ -2,8 +2,8 @@ # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** -# TARGTYPE "Win32 (x86) Static Library" 0x0104 # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 +# TARGTYPE "Win32 (x86) Static Library" 0x0104 CFG=wxWindows - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, @@ -32,8 +32,6 @@ CFG=wxWindows - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe !IF "$(CFG)" == "wxWindows - Win32 Release Unicode DLL" @@ -48,10 +46,13 @@ RSC=rc.exe # PROP Intermediate_Dir "../ReleaseUnicodeDll" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MD /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdllu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdllu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "NDEBUG" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c +MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +RSC=rc.exe # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /i "../include" /d "NDEBUG" BSC32=bscmake.exe @@ -74,17 +75,20 @@ LINK32=link.exe # PROP Intermediate_Dir "../DebugUnicodeDll" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MDd /W4 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdllud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdllud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "_DEBUG" /D "WXMAKINGDLL" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c +MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +RSC=rc.exe # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /i "../include" /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /pdbtype:sept /out:"../lib/wxmsw250ud.dll" +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /out:"../lib/wxmsw250ud.dll" /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib odbc32.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxmsw250ud.dll" !ELSEIF "$(CFG)" == "wxWindows - Win32 Release Unicode" @@ -99,8 +103,10 @@ LINK32=link.exe # PROP Output_Dir "../lib" # PROP Intermediate_Dir "../ReleaseUnicode" # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "_UNICODE" /D "UNICODE" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswu" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c +RSC=rc.exe # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe @@ -122,8 +128,10 @@ LIB32=link.exe -lib # PROP Output_Dir "../lib" # PROP Intermediate_Dir "../DebugUnicode" # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "_DEBUG" /D "__WXDEBUG__" /D WINVER=0x0400 /D "STRICT" /D "_UNICODE" /D "UNICODE" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswud" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_DEBUG" /D "__WXDEBUG__" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c +RSC=rc.exe # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe @@ -146,10 +154,13 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "../ReleaseDll" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MD /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdll" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MD /W4 /O2 /I "../lib/mswdll" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "NDEBUG" /D "WXMAKINGDLL" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c +MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +RSC=rc.exe # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /i "../include" /d "NDEBUG" BSC32=bscmake.exe @@ -172,17 +183,20 @@ LINK32=link.exe # PROP Intermediate_Dir "../DebugDll" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MDd /W4 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WXWINDLL_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdlld" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /D WINVER=0x0400 /D "STRICT" /D "WXMAKINGDLL" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswdlld" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_USRDLL" /D "_DEBUG" /D "WXMAKINGDLL" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c +MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +RSC=rc.exe # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /i "../include" /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /pdbtype:sept /out:"../lib/wxmsw250d.dll" +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /dll /debug /machine:I386 /out:"../lib/wxmsw250d.dll" /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib odbc32.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib winmm.lib ..\lib\jpegd.lib ..\lib\tiffd.lib ..\lib\pngd.lib ..\lib\regexd.lib ..\lib\zlibd.lib /nologo /version:2.5 /dll /machine:I386 /out:"../lib/wxmsw250d.dll" !ELSEIF "$(CFG)" == "wxWindows - Win32 Release" @@ -197,8 +211,10 @@ LINK32=link.exe # PROP Output_Dir "../lib" # PROP Intermediate_Dir "../Release" # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MD /W4 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W4 /O2 /I "../lib/msw" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "NDEBUG" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MD /W4 /O2 /I "../lib/msw" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "NDEBUG" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c +RSC=rc.exe # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe @@ -220,8 +236,10 @@ LIB32=link.exe -lib # PROP Output_Dir "../lib" # PROP Intermediate_Dir "../Debug" # PROP Target_Dir "" +CPP=cl.exe # ADD BASE CPP /nologo /MDd /W4 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswd" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "WIN32" /D "_DEBUG" /D "__WXDEBUG__" /D WINVER=0x0400 /D "STRICT" /D "__WXBASE__" /Yu"wx/wxprec.h" /FD /c +# ADD CPP /nologo /MDd /W4 /Zi /Od /I "../lib/mswd" /I "../include" /I "./zlib" /I "./jpeg" /I "./png" /I "./regex" /I "./tiff" /D "_DEBUG" /D "__WXDEBUG__" /D "WIN32" /D WINVER=0x0400 /D "STRICT" /D wxUSE_BASE=1 /Yu"wx/wxprec.h" /FD /c +RSC=rc.exe # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe @@ -396,6 +414,11 @@ SOURCE=.\common\event.cpp # End Source File # Begin Source File +SOURCE=.\common\extended.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + SOURCE=.\common\fddlgcmn.cpp # End Source File # Begin Source File @@ -544,6 +567,10 @@ SOURCE=.\common\imagxpm.cpp # End Source File # Begin Source File +SOURCE=.\common\init.cpp +# End Source File +# Begin Source File + SOURCE=.\common\intl.cpp # End Source File # Begin Source File @@ -736,6 +763,11 @@ SOURCE=.\common\txtstrm.cpp # End Source File # Begin Source File +SOURCE=.\common\unzip.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + SOURCE=.\common\url.cpp # End Source File # Begin Source File @@ -782,18 +814,6 @@ SOURCE=.\common\zipstrm.cpp SOURCE=.\common\zstream.cpp # End Source File - -# Begin Source File - -SOURCE=.\common\extended.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=.\common\unzip.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File - # End Group # Begin Group "Generic Files" @@ -910,7 +930,6 @@ SOURCE=.\generic\treectlg.cpp SOURCE=.\generic\wizard.cpp # End Source File - # End Group # Begin Group "wxHTML Files" @@ -995,16 +1014,42 @@ SOURCE=.\html\m_tables.cpp SOURCE=.\html\winpars.cpp # End Source File - # End Group # Begin Group "MSW Files" +# PROP Default_Filter "" +# Begin Group "OLE Files" + # PROP Default_Filter "" # Begin Source File -SOURCE=.\msw\dummy.cpp -# ADD CPP /Yc"wx/wxprec.h" +SOURCE=.\msw\ole\access.cpp +# End Source File +# Begin Source File + +SOURCE=.\msw\ole\automtn.cpp +# End Source File +# Begin Source File + +SOURCE=.\msw\ole\dataobj.cpp +# End Source File +# Begin Source File + +SOURCE=.\msw\ole\dropsrc.cpp +# End Source File +# Begin Source File + +SOURCE=.\msw\ole\droptgt.cpp +# End Source File +# Begin Source File + +SOURCE=.\msw\ole\oleutils.cpp +# End Source File +# Begin Source File + +SOURCE=.\msw\ole\uuid.cpp # End Source File +# End Group # Begin Source File SOURCE=.\msw\accel.cpp @@ -1131,6 +1176,11 @@ SOURCE=.\msw\dragimag.cpp # End Source File # Begin Source File +SOURCE=.\msw\dummy.cpp +# ADD CPP /Yc"wx/wxprec.h" +# End Source File +# Begin Source File + SOURCE=.\msw\enhmeta.cpp # End Source File # Begin Source File @@ -1183,6 +1233,16 @@ SOURCE=.\msw\glcanvas.cpp # End Source File # Begin Source File +SOURCE=.\msw\gsocket.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + +SOURCE=.\msw\gsockmsw.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + SOURCE=.\msw\helpbest.cpp # End Source File # Begin Source File @@ -1421,51 +1481,6 @@ SOURCE=.\msw\wave.cpp SOURCE=.\msw\window.cpp # End Source File - -# Begin Source File - -SOURCE=.\msw\gsocket.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=.\msw\gsockmsw.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File - -# Begin Group "OLE Files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\msw\ole\access.cpp -# End Source File -# Begin Source File - -SOURCE=.\msw\ole\automtn.cpp -# End Source File -# Begin Source File - -SOURCE=.\msw\ole\dataobj.cpp -# End Source File -# Begin Source File - -SOURCE=.\msw\ole\dropsrc.cpp -# End Source File -# Begin Source File - -SOURCE=.\msw\ole\droptgt.cpp -# End Source File -# Begin Source File - -SOURCE=.\msw\ole\oleutils.cpp -# End Source File -# Begin Source File - -SOURCE=.\msw\ole\uuid.cpp -# End Source File - -# End Group # End Group # Begin Group "Headers" @@ -1476,7 +1491,9 @@ SOURCE=.\msw\ole\uuid.cpp # Begin Source File SOURCE=..\include\wx\msw\setup.h + !IF "$(CFG)" == "wxWindows - Win32 Release Unicode DLL" + # Begin Custom Build - Creating ..\lib\mswdllu\wx\setup.h from $(InputPath) InputPath=..\include\wx\msw\setup.h @@ -1484,7 +1501,9 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\mswdllu\wx\setup.h # End Custom Build + !ELSEIF "$(CFG)" == "wxWindows - Win32 Debug Unicode DLL" + # Begin Custom Build - Creating ..\lib\mswdllud\wx\setup.h from $(InputPath) InputPath=..\include\wx\msw\setup.h @@ -1492,7 +1511,9 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\mswdllud\wx\setup.h # End Custom Build + !ELSEIF "$(CFG)" == "wxWindows - Win32 Release Unicode" + # Begin Custom Build - Creating ..\lib\mswu\wx\setup.h from $(InputPath) InputPath=..\include\wx\msw\setup.h @@ -1500,7 +1521,9 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\mswu\wx\setup.h # End Custom Build + !ELSEIF "$(CFG)" == "wxWindows - Win32 Debug Unicode" + # Begin Custom Build - Creating ..\lib\mswud\wx\setup.h from $(InputPath) InputPath=..\include\wx\msw\setup.h @@ -1508,7 +1531,9 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\mswud\wx\setup.h # End Custom Build + !ELSEIF "$(CFG)" == "wxWindows - Win32 Release DLL" + # Begin Custom Build - Creating ..\lib\mswdll\wx\setup.h from $(InputPath) InputPath=..\include\wx\msw\setup.h @@ -1516,7 +1541,9 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\mswdll\wx\setup.h # End Custom Build + !ELSEIF "$(CFG)" == "wxWindows - Win32 Debug DLL" + # Begin Custom Build - Creating ..\lib\mswdlld\wx\setup.h from $(InputPath) InputPath=..\include\wx\msw\setup.h @@ -1524,7 +1551,9 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\mswdlld\wx\setup.h # End Custom Build + !ELSEIF "$(CFG)" == "wxWindows - Win32 Release" + # Begin Custom Build - Creating ..\lib\msw\wx\setup.h from $(InputPath) InputPath=..\include\wx\msw\setup.h @@ -1532,7 +1561,9 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\msw\wx\setup.h # End Custom Build + !ELSEIF "$(CFG)" == "wxWindows - Win32 Debug" + # Begin Custom Build - Creating ..\lib\mswd\wx\setup.h from $(InputPath) InputPath=..\include\wx\msw\setup.h @@ -1540,7 +1571,9 @@ InputPath=..\include\wx\msw\setup.h copy "$(InputPath)" ..\lib\mswd\wx\setup.h # End Custom Build + !ENDIF + # End Source File # End Group # Begin Group "Common" @@ -2490,7 +2523,6 @@ SOURCE=..\include\wx\zipstrm.h SOURCE=..\include\wx\zstream.h # End Source File - # End Group # Begin Group "MSW" @@ -2867,7 +2899,6 @@ SOURCE=..\include\wx\msw\window.h SOURCE=..\include\wx\msw\winundef.h # End Source File - # End Group # Begin Group "Generic" @@ -3028,7 +3059,6 @@ SOURCE=..\include\wx\generic\treectlg.h SOURCE=..\include\wx\generic\wizard.h # End Source File - # End Group # Begin Group "HTML" @@ -3085,7 +3115,6 @@ SOURCE=..\include\wx\html\m_templ.h SOURCE=..\include\wx\html\winpars.h # End Source File - # End Group # End Group # End Target diff --git a/src/x11/app.cpp b/src/x11/app.cpp index a75edfee09..b24c11fbab 100644 --- a/src/x11/app.cpp +++ b/src/x11/app.cpp @@ -93,33 +93,19 @@ BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) EVT_IDLE(wxApp::OnIdle) END_EVENT_TABLE() -bool wxApp::Initialize() +bool wxApp::Initialize(int argc, wxChar **argv) { - wxClassInfo::InitializeClasses(); + if ( !wxAppBase::Initialize(argc, argv) ) + return false; #if wxUSE_INTL wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); #endif - // GL: I'm annoyed ... I don't know where to put this and I don't want to - // create a module for that as it's part of the core. -#if wxUSE_THREADS - wxPendingEventsLocker = new wxCriticalSection(); -#endif - - wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); - wxTheColourDatabase->Initialize(); - - wxInitializeStockLists(); - wxInitializeStockObjects(); - wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER); wxClientWidgetHashTable = new wxHashTable(wxKEY_INTEGER); - wxModule::RegisterModules(); - if (!wxModule::InitializeModules()) return FALSE; - - return TRUE; + return true; } void wxApp::CleanUp() @@ -129,42 +115,7 @@ void wxApp::CleanUp() delete wxClientWidgetHashTable; wxClientWidgetHashTable = NULL; - wxModule::CleanUpModules(); - - delete wxTheColourDatabase; - wxTheColourDatabase = NULL; - - wxDeleteStockObjects(); - - wxDeleteStockLists(); - - delete wxTheApp; - wxTheApp = NULL; - - wxClassInfo::CleanUpClasses(); - -#if wxUSE_THREADS - delete wxPendingEvents; - delete wxPendingEventsLocker; -#endif - -#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) - { - wxLogDebug("There were memory leaks."); - wxDebugContext::Dump(); - wxDebugContext::PrintStatistics(); - } -#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); + wxAppBase::CleanUp(); } // NB: argc and argv may be changed here, pass by reference! @@ -935,24 +886,6 @@ bool wxApp::SendIdleEvents(wxWindow* win) return needMore; } -void wxApp::DeletePendingObjects() -{ - wxNode *node = wxPendingDelete.GetFirst(); - while (node) - { - wxObject *obj = (wxObject *)node->GetData(); - - delete obj; - - if (wxPendingDelete.Member(obj)) - delete node; - - // Deleting one object may have deleted other pending - // objects, so start from beginning of list again. - node = wxPendingDelete.GetFirst(); - } -} - // Create display, and other initialization bool wxApp::OnInitGui() { -- 2.45.2