]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/helpers.cpp
corrections to dynamic loading for Darwin
[wxWidgets.git] / wxPython / src / helpers.cpp
index 0943cabc006302e47d3ab25c8cdaf1d71fb32b84..340c740037478fa4367ec95e01e4c53c3dc30d3a 100644 (file)
@@ -223,11 +223,13 @@ PyObject* __wxStart(PyObject* /* self */, PyObject* args)
 
 void __wxCleanup() {
     wxEntryCleanup();
+#ifdef WXP_WITH_THREAD
     delete wxPyTMutex;
     wxPyTMutex = NULL;
     wxPyTStates->Empty();
     delete wxPyTStates;
     wxPyTStates = NULL;
+#endif
 }
 
 
@@ -254,8 +256,8 @@ PyObject* __wxSetDictionary(PyObject* /* self */, PyObject* args)
 #ifdef __WXMOTIF__
 #define wxPlatform "__WXMOTIF__"
 #endif
-#ifdef __WXQT__
-#define wxPlatform "__WXQT__"
+#ifdef __WXX11__
+#define wxPlatform "__WXX11__"
 #endif
 #ifdef __WXGTK__
 #define wxPlatform "__WXGTK__"
@@ -448,9 +450,12 @@ unsigned long wxPyGetCurrentThreadId() {
     return wxThread::GetCurrentId();
 }
 
-
+static PyThreadState* gs_shutdownTState;
 static
 PyThreadState* wxPyGetThreadState() {
+    if (wxPyTMutex == NULL) // Python is shutting down...
+        return gs_shutdownTState;
+
     unsigned long ctid = wxPyGetCurrentThreadId();
     PyThreadState* tstate = NULL;
 
@@ -469,6 +474,10 @@ PyThreadState* wxPyGetThreadState() {
 
 static
 void wxPySaveThreadState(PyThreadState* tstate) {
+    if (wxPyTMutex == NULL) { // Python is shutting down, assume a single thread...
+        gs_shutdownTState = tstate;
+        return;
+    }
     unsigned long ctid = wxPyGetCurrentThreadId();
     wxPyTMutex->Lock();
     for(size_t i=0; i < wxPyTStates->GetCount(); i++) {
@@ -1490,6 +1499,18 @@ PyObject* wxArrayString2PyList_helper(const wxArrayString& arr) {
 }
 
 
+PyObject* wxArrayInt2PyList_helper(const wxArrayInt& arr) {
+
+    PyObject* list = PyList_New(0);
+    for (size_t i=0; i < arr.GetCount(); i++) {
+        PyObject* number = PyInt_FromLong(arr[i]);
+        PyList_Append(list, number);
+        Py_DECREF(number);
+    }
+    return list;
+}
+
+
 //----------------------------------------------------------------------
 //----------------------------------------------------------------------