wxPython now creates it's own Python thread state instead of using the
authorRobin Dunn <robin@alldunn.com>
Mon, 2 Apr 2001 03:43:04 +0000 (03:43 +0000)
committerRobin Dunn <robin@alldunn.com>
Mon, 2 Apr 2001 03:43:04 +0000 (03:43 +0000)
one that was active when it starts up.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9632 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/src/helpers.cpp

index 28d810873f2a315abf7c8521d5bab4fc426fa415..d07600f82b2305f34219b12c086dbc4151572eb9 100644 (file)
@@ -122,8 +122,13 @@ void __wxPreStart()
 #endif
 
 #ifdef WXP_WITH_THREAD
+#if 0   // OLD THREAD STUFF
     PyEval_InitThreads();
     wxPyEventThreadState = PyThreadState_Get();
+#else
+    PyEval_InitThreads();
+    wxPyEventThreadState = PyThreadState_New(PyThreadState_Get()->interp);
+#endif
 #endif
 
     // Bail out if there is already windows created.  This means that the
@@ -308,11 +313,19 @@ bool wxPyRestoreThread() {
     // already have the lock.  (I hope!)
     //
 #ifdef WXP_WITH_THREAD
+#if 0   // OLD THREAD STUFF
     if (wxPyEventThreadState != myPyThreadState_Get()) {
         PyEval_RestoreThread(wxPyEventThreadState);
         return TRUE;
     }
     else
+#else
+    if (wxPyEventThreadState != myPyThreadState_Get()) {
+        PyEval_AcquireThread(wxPyEventThreadState);
+        return TRUE;
+    }
+    else
+#endif
 #endif
         return FALSE;
 }
@@ -320,9 +333,15 @@ bool wxPyRestoreThread() {
 
 void wxPySaveThread(bool doSave) {
 #ifdef WXP_WITH_THREAD
+#if 0   // OLD THREAD STUFF
     if (doSave) {
         wxPyEventThreadState = PyEval_SaveThread();
     }
+#else
+    if (doSave) {
+        PyEval_ReleaseThread(wxPyEventThreadState);
+    }
+#endif
 #endif
 }
 
@@ -988,7 +1007,7 @@ bool wxColour_helper(PyObject* source, wxColour** obj) {
     // otherwise a string is expected
     else if (PyString_Check(source)) {
         wxString spec = PyString_AS_STRING(source);
-        if (spec[0] == '#' && spec.Length() == 7) {  // It's  #RRGGBB
+        if (spec[0U] == '#' && spec.Length() == 7) {  // It's  #RRGGBB
             char* junk;
             int red   = strtol(spec.Mid(1,2), &junk, 16);
             int green = strtol(spec.Mid(3,2), &junk, 16);