- wxPyThreadState* tstate = wxPyGetThreadState();
- if (tstate->blocked++ == 0) { // if nested calls then do nothing
+ // 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);
+
+ // Only block if there wasn't alrady a tstate. This cen happen with
+ // nested calls to wxPyBeginBlockThreads
+ bool blocked = false;
+ if (current == NULL) {
+ wxPyThreadState* tstate = wxPyGetThreadState();