X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/27c9e43cc09bb6ba136a5a3897232d73df1e878f..42f8298f6f42d5d63bb3caf65682b7d9d9f8b702:/wxPython/src/helpers.cpp?ds=sidebyside diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index ef5fb35e32..512b685baa 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -866,10 +866,8 @@ bool wxPyCheckForApp() { //--------------------------------------------------------------------------- - -void wxPyClientData_dtor(wxPyClientData* self) { - if (! wxPyDoingCleanup) { // Don't do it during cleanup as Python - // may have already garbage collected the object... +void wxPyUserData_dtor(wxPyUserData* self) { + if (! wxPyDoingCleanup) { bool blocked = wxPyBeginBlockThreads(); Py_DECREF(self->m_obj); self->m_obj = NULL; @@ -877,16 +875,21 @@ void wxPyClientData_dtor(wxPyClientData* self) { } } -void wxPyUserData_dtor(wxPyUserData* self) { - if (! wxPyDoingCleanup) { - bool blocked = wxPyBeginBlockThreads(); - Py_DECREF(self->m_obj); + +void wxPyClientData_dtor(wxPyClientData* self) { + if (! wxPyDoingCleanup) { // Don't do it during cleanup as Python + // may have already garbage collected the object... + if (self->m_incRef) { + bool blocked = wxPyBeginBlockThreads(); + Py_DECREF(self->m_obj); + wxPyEndBlockThreads(blocked); + } self->m_obj = NULL; - wxPyEndBlockThreads(blocked); } } + // This is called when an OOR controled object is being destroyed. Although // the C++ object is going away there is no way to force the Python object // (and all references to it) to die too. This causes problems (crashes) in @@ -909,8 +912,9 @@ void wxPyOORClientData_dtor(wxPyOORClientData* self) { } - // Only if there is more than one reference to the object - if ( !wxPyDoingCleanup && self->m_obj->ob_refcnt > 1 ) { + // Only if there is more than one reference to the object and we are + // holding the OOR reference: + if ( !wxPyDoingCleanup && self->m_obj->ob_refcnt > 1 && self->m_incRef) { // bool isInstance = wxPyInstance_Check(self->m_obj); // TODO same here //wxASSERT_MSG(isInstance, wxT("m_obj not an instance!?!?!")); @@ -1473,7 +1477,7 @@ wxFileOffset wxPyCBInputStream::OnSysTell() const { //---------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxPyCallback, wxObject); +IMPLEMENT_ABSTRACT_CLASS(wxPyCallback, wxEvtHandler); wxPyCallback::wxPyCallback(PyObject* func) { m_func = func;