Fixed a fatal bug that sometimes happens when wxPython objects are
destroyed while Python is cleaning itself up at exit. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18468 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -46,6 +46,7 @@ void WXDLLEXPORT wxEntryCleanup();
|
||||
|
||||
wxPyApp* wxPythonApp = NULL; // Global instance of application object
|
||||
bool wxPyDoCleanup = FALSE;
|
||||
bool wxPyDoingCleanup = FALSE;
|
||||
|
||||
|
||||
#ifdef WXP_WITH_THREAD
|
||||
@@ -379,6 +380,7 @@ PyObject* __wxStart(PyObject* /* self */, PyObject* args)
|
||||
|
||||
|
||||
void __wxCleanup() {
|
||||
wxPyDoingCleanup = TRUE;
|
||||
if (wxPyDoCleanup)
|
||||
wxEntryCleanup();
|
||||
#ifdef WXP_WITH_THREAD
|
||||
@@ -442,15 +444,20 @@ PyObject* __wxSetDictionary(PyObject* /* self */, PyObject* args)
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void wxPyClientData_dtor(wxPyClientData* self) {
|
||||
wxPyBeginBlockThreads();
|
||||
Py_DECREF(self->m_obj);
|
||||
wxPyEndBlockThreads();
|
||||
if (! wxPyDoingCleanup) { // Don't do it during cleanup as Python
|
||||
// may have already garbage collected the object...
|
||||
wxPyBeginBlockThreads();
|
||||
Py_DECREF(self->m_obj);
|
||||
wxPyEndBlockThreads();
|
||||
}
|
||||
}
|
||||
|
||||
void wxPyUserData_dtor(wxPyUserData* self) {
|
||||
wxPyBeginBlockThreads();
|
||||
Py_DECREF(self->m_obj);
|
||||
wxPyEndBlockThreads();
|
||||
if (! wxPyDoingCleanup) {
|
||||
wxPyBeginBlockThreads();
|
||||
Py_DECREF(self->m_obj);
|
||||
wxPyEndBlockThreads();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -473,6 +480,8 @@ void wxPyOORClientData_dtor(wxPyOORClientData* self) {
|
||||
Py_INCREF(deadObjectClass);
|
||||
}
|
||||
|
||||
// TODO: If wxPyDOingCleanup, should we skip the code below?
|
||||
|
||||
// Clear the instance's dictionary, put the name of the old class into the
|
||||
// instance, and then reset the class to be the dead class.
|
||||
if (self->m_obj->ob_refcnt > 1) { // but only if there is more than one reference
|
||||
|
Reference in New Issue
Block a user