X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/da32eb53cbe7947f3f4599d7b6b5caa21a68d27f..dcc1aa238271267e92069d834781ee8fd15007bd:/wxPython/src/helpers.cpp diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index 81c954bc70..7ad042c032 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -723,6 +723,16 @@ void wxPy_ReinitStockObjects(int pass) else if (pass == 2) { rsoPass2(#name); } \ else if (pass == 3) { rsoPass3(#name, #classname, (void*)&name); } + // If there is already an App object then wxPython is probably embedded in + // a wx C++ application, so there is no need to do all this. + static bool embedded = false; + if ((pass == 1 || pass == 2) && wxTheApp) { + embedded = true; + return; + } + if (pass == 3 && embedded) + return; + REINITOBJ(wxNORMAL_FONT, wxFont); REINITOBJ(wxSMALL_FONT, wxFont); @@ -1059,15 +1069,14 @@ bool wxPyBeginBlockThreads() { // This works in for 2.3, maybe a good alternative to find the needed tstate? // PyThreadState *check = PyGILState_GetThisThreadState(); - // get the currect tstate by swapping in NULL and then putting it back. - PyThreadState *current = PyThreadState_Swap(NULL); - PyThreadState_Swap(current); + PyThreadState *current = _PyThreadState_Current; - // Only block if there wasn't alrady a tstate. This cen happen with - // nested calls to wxPyBeginBlockThreads + // Only block if there wasn't already a tstate, or if the current one is + // not the one we are wanting to change to. This should prevent deadlock + // if there are nested calls to wxPyBeginBlockThreads bool blocked = false; - if (current == NULL) { - wxPyThreadState* tstate = wxPyGetThreadState(); + wxPyThreadState* tstate = wxPyGetThreadState(); + if (current != tstate->tstate) { PyEval_RestoreThread(tstate->tstate); blocked = true; }