X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/69ac96fd0d0e7b9d0fb1b349fe043502380ca929..3a9becbd5439254a77e7dbc0278d80117a397264:/wxPython/src/helpers.cpp diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index f37f539eca..a1a20b66fa 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -442,7 +442,7 @@ void wxPyApp::_BootstrapApp() setlocale(LC_NUMERIC, "C"); #endif - wxSystemOptions::SetOption(wxT("mac.textcontrol-use-mlte"), 1); +// wxSystemOptions::SetOption(wxT("mac.textcontrol-use-mlte"), 1); // The stock objects were all NULL when they were loaded into // SWIG generated proxies, so re-init those now... @@ -451,6 +451,11 @@ void wxPyApp::_BootstrapApp() wxPyEndBlockThreads(blocked); haveInitialized = true; } + else { + this->argc = 0; + this->argv = NULL; + } + // It's now ok to generate exceptions for assertion errors. wxPythonApp->SetStartupComplete(true); @@ -996,6 +1001,7 @@ void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName) { PyObject* wxPyMake_wxObject(wxObject* source, bool setThisOwn, bool checkEvtHandler) { PyObject* target = NULL; bool isEvtHandler = false; + bool isSizer = false; if (source) { // If it's derived from wxEvtHandler then there may @@ -1012,6 +1018,18 @@ PyObject* wxPyMake_wxObject(wxObject* source, bool setThisOwn, bool checkEvtHan } } + // Also check for wxSizer + if (!target && wxIsKindOf(source, wxSizer)) { + isSizer = true; + wxSizer* sz = (wxSizer*)source; + wxPyOORClientData* data = (wxPyOORClientData*)sz->GetClientObject(); + if (data) { + target = data->m_obj; + if (target) + Py_INCREF(target); + } + } + if (! target) { // Otherwise make it the old fashioned way by making a new shadow // object and putting this pointer in it. Look up the class @@ -1029,6 +1047,8 @@ PyObject* wxPyMake_wxObject(wxObject* source, bool setThisOwn, bool checkEvtHan target = wxPyConstructObject((void*)source, name, setThisOwn); if (target && isEvtHandler) ((wxEvtHandler*)source)->SetClientObject(new wxPyOORClientData(target)); + if (target && isSizer) + ((wxSizer*)source)->SetClientObject(new wxPyOORClientData(target)); } else { wxString msg(wxT("wxPython class not found for ")); msg += source->GetClassInfo()->GetClassName(); @@ -1044,25 +1064,8 @@ PyObject* wxPyMake_wxObject(wxObject* source, bool setThisOwn, bool checkEvtHan PyObject* wxPyMake_wxSizer(wxSizer* source, bool setThisOwn) { - PyObject* target = NULL; - if (source && wxIsKindOf(source, wxSizer)) { - // If it's derived from wxSizer then there may already be a pointer to - // a Python object that we can use in the OOR data. - wxSizer* sz = (wxSizer*)source; - wxPyOORClientData* data = (wxPyOORClientData*)sz->GetClientObject(); - if (data) { - target = data->m_obj; - if (target) - Py_INCREF(target); - } - } - if (! target) { - target = wxPyMake_wxObject(source, setThisOwn, false); - if (target != Py_None) - ((wxSizer*)source)->SetClientObject(new wxPyOORClientData(target)); - } - return target; + return wxPyMake_wxObject(source, setThisOwn); } @@ -1164,6 +1167,9 @@ void wxPyEndAllowThreads(PyThreadState* saved) { wxPyBlock_t wxPyBeginBlockThreads() { #ifdef WXP_WITH_THREAD + if (! Py_IsInitialized()) { + return (wxPyBlock_t)0; + } #if wxPyUSE_GIL_STATE PyGILState_STATE state = PyGILState_Ensure(); return state; @@ -1182,13 +1188,16 @@ wxPyBlock_t wxPyBeginBlockThreads() { return blocked; #endif #else - return false; + return (wxPyBlock_t)0; #endif } void wxPyEndBlockThreads(wxPyBlock_t blocked) { #ifdef WXP_WITH_THREAD + if (! Py_IsInitialized()) { + return; + } #if wxPyUSE_GIL_STATE PyGILState_Release(blocked); #else