From c1867aef8ddaa0a0ae40b3d865e7273af65c5157 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 12 Sep 2019 19:18:36 -0700 Subject: [PATCH] Merge pull request #1352 from wxWidgets/getapp-issue1126 Remove tracking of application instance in wxPyApp (cherry picked from commit 574049d7cf8ca8ac92ae215fac85487fab01541c) --- etg/app.py | 7 +++---- src/app_ex.cpp | 9 +++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/etg/app.py b/etg/app.py index c026c984..1793eacf 100644 --- a/etg/app.py +++ b/etg/app.py @@ -43,7 +43,7 @@ def run(): etgtools.prependText(c.detailedDoc, "Note that it is not intended for this class to be used directly from " - "Python. It is wrapped just for inheriting its methods from :class:`App`.") + "Python. It is wrapped just for inheriting its methods in :class:`App`.") # There's no need for the command line stuff as Python has its own ways to # deal with that @@ -236,12 +236,11 @@ def run(): module.insertItemBefore(c, enum) module.addHeaderCode("""\ - class wxPyApp; - wxPyApp* wxGetApp(); + wxAppConsole* wxGetApp(); """) module.find('wxTheApp').ignore() f = module.find('wxGetApp') - f.type = 'wxPyApp*' + f.type = 'wxAppConsole*' f.briefDoc = "Returns the current application object." f.detailedDoc = [] diff --git a/src/app_ex.cpp b/src/app_ex.cpp index 7203f890..3c526d31 100644 --- a/src/app_ex.cpp +++ b/src/app_ex.cpp @@ -52,11 +52,10 @@ public: m_assertMode = wxAPP_ASSERT_EXCEPTION; m_startupComplete = false; //m_callFilterEvent = false; - ms_appInstance = this; + wxApp::SetInstance(this); } ~wxPyApp() { - ms_appInstance = NULL; wxApp::SetInstance(NULL); } @@ -118,7 +117,6 @@ public: // implementation only void SetStartupComplete(bool val) { m_startupComplete = val; } - static wxPyApp* ms_appInstance; private: wxAppAssertMode m_assertMode; @@ -128,7 +126,6 @@ private: IMPLEMENT_ABSTRACT_CLASS(wxPyApp, wxApp); -wxPyApp* wxPyApp::ms_appInstance = NULL; extern PyObject* wxAssertionError; // Exception object raised for wxASSERT failures @@ -349,7 +346,7 @@ bool wxPyApp::IsDisplayAvailable() -wxPyApp* wxGetApp() +wxAppConsole* wxGetApp() { - return wxPyApp::ms_appInstance; + return wxApp::GetInstance(); }