A little black magic... When the C++ object (for a window or

whatever) is deleted there is no way to force the Python shadow object
to also be destroyed and clean up all references to it.  This leads to
crashes if the shadow object tries to call a method with the old C++
pointer...  The black magic I've done is to replace the __class__ in the
Python instanc object with a class that raises an exception whenever a
method call is attempted.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15059 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-04-09 22:01:45 +00:00
parent 31fa82942c
commit 4acff284f9
18 changed files with 207 additions and 84 deletions

View File

@@ -172,7 +172,7 @@ PyObject* wxPyMake_wxShapeEvtHandler(wxShapeEvtHandler* source) {
// already be a pointer to a Python object that we can use
// in the OOR data.
wxShapeEvtHandler* seh = (wxShapeEvtHandler*)source;
wxPyClientData* data = (wxPyClientData*)seh->GetClientObject();
wxPyOORClientData* data = (wxPyOORClientData*)seh->GetClientObject();
if (data) {
target = data->m_obj;
Py_INCREF(target);
@@ -181,7 +181,7 @@ PyObject* wxPyMake_wxShapeEvtHandler(wxShapeEvtHandler* source) {
if (! target) {
target = wxPyMake_wxObject2(source, FALSE);
if (target != Py_None)
((wxShapeEvtHandler*)source)->SetClientObject(new wxPyClientData(target));
((wxShapeEvtHandler*)source)->SetClientObject(new wxPyOORClientData(target));
}
return target;
}