From 6907bb85defc3cddec56d397ae052d502df0a452 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 8 Oct 2014 04:33:41 +0000 Subject: [PATCH] Only use CallOnInit the first time, otherwise the 2nd wx.App will block when being constructed. Fixes hang in unittests. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@77977 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/app_ex.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app_ex.cpp b/src/app_ex.cpp index f98ba1da..7e835c8a 100644 --- a/src/app_ex.cpp +++ b/src/app_ex.cpp @@ -242,7 +242,6 @@ void wxPyApp::_BootstrapApp() ); goto error; } - haveInitialized = true; } else { this->argc = 0; @@ -253,11 +252,23 @@ void wxPyApp::_BootstrapApp() // Call the Python wxApp's OnPreInit and OnInit functions if they exist OnPreInit(); - result = CallOnInit(); +#ifdef __WXOSX_COCOA__ + // Only use CallOnInit the first time, otherwise it will block on [NSApp run]; + if (! haveInitialized) + result = CallOnInit(); + else +#endif + result = OnInit(); +//#ifdef __WXOSX_COCOA__ +// OSXSetInitWasCalled(true); TODO: consider adding this method to wxApp +//#endif + if (! result) { wxPyErr_SetString(PyExc_SystemExit, "OnInit returned false, exiting..."); } + + haveInitialized = true; error: return;