X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0e2ff151afc472efd2814c74add5ad4498709d33..f9ee64b1356530b7f5c957d250d2a1dcbef60f60:/wxPython/src/helpers.cpp diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index bb76934d3a..340c740037 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -31,8 +31,11 @@ //---------------------------------------------------------------------- - +#ifdef __WXGTK__ +int WXDLLEXPORT wxEntryStart( int& argc, char** argv ); +#else int WXDLLEXPORT wxEntryStart( int argc, char** argv ); +#endif int WXDLLEXPORT wxEntryInitGui(); void WXDLLEXPORT wxEntryCleanup(); @@ -220,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 } @@ -251,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__" @@ -438,32 +443,19 @@ PyObject* wxPyConstructObject(void* ptr, //--------------------------------------------------------------------------- -// TODO: This should really be wxThread::GetCurrentId(), and I will do so -// after I make a quick 2.3.2.1 release. + #ifdef WXP_WITH_THREAD -#ifdef __WXGTK__ // does wxGTK always use pthreads? -#include -#include -#endif inline unsigned long wxPyGetCurrentThreadId() { -#ifdef __WXMSW__ - return (unsigned long)::GetCurrentThreadId(); -#endif -#ifdef __WXGTK__ // does wxGTK always use pthreads? - return (unsigned long)pthread_self(); -#endif -#ifdef __WXMAC__ - ThreadID current ; - MacGetCurrentThread( ¤t ) ; - return (unsigned long)current; -#endif + 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; @@ -482,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++) { @@ -1503,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; +} + + //---------------------------------------------------------------------- //----------------------------------------------------------------------