Merge pull request #1352 from wxWidgets/getapp-issue1126

Remove tracking of application instance in wxPyApp

(cherry picked from commit 574049d7cf)
This commit is contained in:
Robin Dunn
2019-09-12 19:18:36 -07:00
committed by Robin Dunn
parent ec761b32f5
commit c1867aef8d
2 changed files with 6 additions and 10 deletions

View File

@@ -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 = []

View File

@@ -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();
}