]> git.saurik.com Git - wxWidgets.git/commitdiff
wxTheApp can't be assigned to, anyhow, so make ms_appInstance private and provide...
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 1 Aug 2003 23:37:40 +0000 (23:37 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 1 Aug 2003 23:37:40 +0000 (23:37 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22462 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/app.h
src/common/init.cpp

index 1a356a01d8db1599210634a147145b40352b1c2a..a06b1f7485600732db9d95c0ec02034750a75a0e 100644 (file)
@@ -270,15 +270,18 @@ public:
     static wxAppInitializerFunction GetInitializerFunction()
         { return ms_appInitFn; }
 
     static wxAppInitializerFunction GetInitializerFunction()
         { return ms_appInitFn; }
 
+    // accessors for ms_appInstance field (external code might wish to modify
+    // it, this is why we provide a setter here as well, but you should really
+    // know what you're doing if you call it), wxTheApp is usually used instead
+    // of GetInstance()
+    static wxAppConsole *GetInstance() { return ms_appInstance; }
+    static void SetInstance(wxAppConsole *app) { ms_appInstance = app; }
+
 
     // command line arguments (public for backwards compatibility)
     int      argc;
     wxChar **argv;
 
 
     // command line arguments (public for backwards compatibility)
     int      argc;
     wxChar **argv;
 
-    // the one and only global application object (must be public for backwards
-    // compatibility as assigning to wxTheApp should work)
-    static wxAppConsole *ms_appInstance;
-
 protected:
     // the function which creates the traits object when GetTraits() needs it
     // for the first time
 protected:
     // the function which creates the traits object when GetTraits() needs it
     // for the first time
@@ -288,6 +291,9 @@ protected:
     // function used for dynamic wxApp creation
     static wxAppInitializerFunction ms_appInitFn;
 
     // function used for dynamic wxApp creation
     static wxAppInitializerFunction ms_appInitFn;
 
+    // the one and only global application object
+    static wxAppConsole *ms_appInstance;
+
 
     // application info (must be set from the user code)
     wxString m_vendorName,      // vendor name (ACME Inc)
 
     // application info (must be set from the user code)
     wxString m_vendorName,      // vendor name (ACME Inc)
@@ -534,7 +540,7 @@ protected:
 //
 // the cast is safe as in GUI build we only use wxApp, not wxAppConsole, and in
 // console mode it does nothing at all
 //
 // the cast is safe as in GUI build we only use wxApp, not wxAppConsole, and in
 // console mode it does nothing at all
-#define wxTheApp ((wxApp *)wxApp::ms_appInstance)
+#define wxTheApp ((wxApp *)wxApp::GetInstance())
 
 // ----------------------------------------------------------------------------
 // global functions
 
 // ----------------------------------------------------------------------------
 // global functions
index a797719db46546ef9d9d89a9398c238cb7af66f7..72c8968ed4680f0d769396270d3c3deb88c939d9 100644 (file)
@@ -81,7 +81,7 @@ public:
         {
             // the pointer is going to be deleted in the base class dtor, don't
             // leave the dangling pointer!
         {
             // the pointer is going to be deleted in the base class dtor, don't
             // leave the dangling pointer!
-            wxTheApp = NULL;
+            wxApp::SetInstance(NULL);
         }
     }
 
         }
     }
 
@@ -89,7 +89,7 @@ public:
     {
         reset(ptr);
 
     {
         reset(ptr);
 
-        wxTheApp = ptr;
+        wxApp::SetInstance(ptr);
     }
 
     DECLARE_NO_COPY_CLASS(wxAppPtr)
     }
 
     DECLARE_NO_COPY_CLASS(wxAppPtr)
@@ -356,7 +356,7 @@ void wxEntryCleanup()
         wxTheApp->CleanUp();
 
         delete wxTheApp;
         wxTheApp->CleanUp();
 
         delete wxTheApp;
-        wxTheApp = NULL;
+        wxApp::SetInstance(NULL);
     }
 
 
     }