From ea19c9a89937acd985f3ea5471b13aaa60bdca07 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 11 May 2005 17:06:22 +0000 Subject: [PATCH] Ensure that Python is initialized before doing any locking in wxPyBeginBlockThreads and wxPyEndBlockThreads as these can be triggered after Python has been finalized in embedding situations. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34018 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/helpers.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index 96bed66402..59499e566a 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -1167,6 +1167,9 @@ void wxPyEndAllowThreads(PyThreadState* saved) { wxPyBlock_t wxPyBeginBlockThreads() { #ifdef WXP_WITH_THREAD + if (! Py_IsInitialized()) { + return (wxPyBlock_t)0; + } #if wxPyUSE_GIL_STATE PyGILState_STATE state = PyGILState_Ensure(); return state; @@ -1192,6 +1195,9 @@ wxPyBlock_t wxPyBeginBlockThreads() { void wxPyEndBlockThreads(wxPyBlock_t blocked) { #ifdef WXP_WITH_THREAD + if (! Py_IsInitialized()) { + return; + } #if wxPyUSE_GIL_STATE PyGILState_Release(blocked); #else -- 2.50.0