a bug fix in helpers for ref-counting callbacks

some generated code updates


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4667 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
1999-11-23 20:36:23 +00:00
parent 80eab46937
commit b731267565
6 changed files with 129 additions and 110 deletions

View File

@@ -223,6 +223,8 @@ public:
const wxIcon &go = wxNullIcon) const wxIcon &go = wxNullIcon)
: wxDropSource(win, go) {} : wxDropSource(win, go) {}
#endif #endif
~wxPyDropSource() { printf("dtor\n"); }
DEC_PYCALLBACK_BOOL_DR(GiveFeedback); DEC_PYCALLBACK_BOOL_DR(GiveFeedback);
PYPRIVATE; PYPRIVATE;
}; };
@@ -2211,17 +2213,18 @@ static PyObject *_wrap_new_wxDropSource(PyObject *self, PyObject *args, PyObject
return _resultobj; return _resultobj;
} }
#define wxDropSource__setSelf(_swigobj,_swigarg0) (_swigobj->_setSelf(_swigarg0)) #define wxDropSource__setSelf(_swigobj,_swigarg0,_swigarg1) (_swigobj->_setSelf(_swigarg0,_swigarg1))
static PyObject *_wrap_wxDropSource__setSelf(PyObject *self, PyObject *args, PyObject *kwargs) { static PyObject *_wrap_wxDropSource__setSelf(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj; PyObject * _resultobj;
wxPyDropSource * _arg0; wxPyDropSource * _arg0;
PyObject * _arg1; PyObject * _arg1;
int _arg2;
PyObject * _argo0 = 0; PyObject * _argo0 = 0;
PyObject * _obj1 = 0; PyObject * _obj1 = 0;
char *_kwnames[] = { "self","self", NULL }; char *_kwnames[] = { "self","self","incref", NULL };
self = self; self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxDropSource__setSelf",_kwnames,&_argo0,&_obj1)) if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OOi:wxDropSource__setSelf",_kwnames,&_argo0,&_obj1,&_arg2))
return NULL; return NULL;
if (_argo0) { if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; } if (_argo0 == Py_None) { _arg0 = NULL; }
@@ -2235,7 +2238,7 @@ static PyObject *_wrap_wxDropSource__setSelf(PyObject *self, PyObject *args, PyO
} }
{ {
wxPy_BEGIN_ALLOW_THREADS; wxPy_BEGIN_ALLOW_THREADS;
wxDropSource__setSelf(_arg0,_arg1); wxDropSource__setSelf(_arg0,_arg1,_arg2);
wxPy_END_ALLOW_THREADS; wxPy_END_ALLOW_THREADS;
} Py_INCREF(Py_None); } Py_INCREF(Py_None);
@@ -2262,7 +2265,9 @@ static PyObject *_wrap_delete_wxDropSource(PyObject *self, PyObject *args, PyObj
} }
{ {
wxPy_BEGIN_ALLOW_THREADS; wxPy_BEGIN_ALLOW_THREADS;
printf("before dtor\n");
delete_wxPyDropSource(_arg0); delete_wxPyDropSource(_arg0);
printf("after dtor\n");
wxPy_END_ALLOW_THREADS; wxPy_END_ALLOW_THREADS;
} Py_INCREF(Py_None); } Py_INCREF(Py_None);

View File

@@ -333,7 +333,7 @@ class wxDropSource(wxDropSourcePtr):
def __init__(self,*_args,**_kwargs): def __init__(self,*_args,**_kwargs):
self.this = apply(clip_dndc.new_wxDropSource,_args,_kwargs) self.this = apply(clip_dndc.new_wxDropSource,_args,_kwargs)
self.thisown = 1 self.thisown = 1
self._setSelf(self) self._setSelf(self, 0)

View File

@@ -2071,11 +2071,16 @@ SWIGEXPORT(void) initwxc() {
PyDict_SetItemString(d,"wxCOLOURED", PyInt_FromLong((long) wxCOLOURED)); PyDict_SetItemString(d,"wxCOLOURED", PyInt_FromLong((long) wxCOLOURED));
PyDict_SetItemString(d,"wxFIXED_LENGTH", PyInt_FromLong((long) wxFIXED_LENGTH)); PyDict_SetItemString(d,"wxFIXED_LENGTH", PyInt_FromLong((long) wxFIXED_LENGTH));
PyDict_SetItemString(d,"wxALIGN_LEFT", PyInt_FromLong((long) wxALIGN_LEFT)); PyDict_SetItemString(d,"wxALIGN_LEFT", PyInt_FromLong((long) wxALIGN_LEFT));
PyDict_SetItemString(d,"wxALIGN_CENTER", PyInt_FromLong((long) wxALIGN_CENTER)); PyDict_SetItemString(d,"wxALIGN_CENTER_HORIZONTAL", PyInt_FromLong((long) wxALIGN_CENTER_HORIZONTAL));
PyDict_SetItemString(d,"wxALIGN_CENTRE", PyInt_FromLong((long) wxALIGN_CENTRE)); PyDict_SetItemString(d,"wxALIGN_CENTRE_HORIZONTAL", PyInt_FromLong((long) wxALIGN_CENTRE_HORIZONTAL));
PyDict_SetItemString(d,"wxALIGN_RIGHT", PyInt_FromLong((long) wxALIGN_RIGHT)); PyDict_SetItemString(d,"wxALIGN_RIGHT", PyInt_FromLong((long) wxALIGN_RIGHT));
PyDict_SetItemString(d,"wxALIGN_BOTTOM", PyInt_FromLong((long) wxALIGN_BOTTOM)); PyDict_SetItemString(d,"wxALIGN_BOTTOM", PyInt_FromLong((long) wxALIGN_BOTTOM));
PyDict_SetItemString(d,"wxALIGN_CENTER_VERTICAL", PyInt_FromLong((long) wxALIGN_CENTER_VERTICAL));
PyDict_SetItemString(d,"wxALIGN_CENTRE_VERTICAL", PyInt_FromLong((long) wxALIGN_CENTRE_VERTICAL));
PyDict_SetItemString(d,"wxALIGN_TOP", PyInt_FromLong((long) wxALIGN_TOP)); PyDict_SetItemString(d,"wxALIGN_TOP", PyInt_FromLong((long) wxALIGN_TOP));
PyDict_SetItemString(d,"wxALIGN_CENTER", PyInt_FromLong((long) wxALIGN_CENTER));
PyDict_SetItemString(d,"wxALIGN_CENTRE", PyInt_FromLong((long) wxALIGN_CENTRE));
PyDict_SetItemString(d,"wxSHAPED", PyInt_FromLong((long) wxSHAPED));
PyDict_SetItemString(d,"wxLB_NEEDED_SB", PyInt_FromLong((long) wxLB_NEEDED_SB)); PyDict_SetItemString(d,"wxLB_NEEDED_SB", PyInt_FromLong((long) wxLB_NEEDED_SB));
PyDict_SetItemString(d,"wxLB_ALWAYS_SB", PyInt_FromLong((long) wxLB_ALWAYS_SB)); PyDict_SetItemString(d,"wxLB_ALWAYS_SB", PyInt_FromLong((long) wxLB_ALWAYS_SB));
PyDict_SetItemString(d,"wxLB_SORT", PyInt_FromLong((long) wxLB_SORT)); PyDict_SetItemString(d,"wxLB_SORT", PyInt_FromLong((long) wxLB_SORT));

View File

@@ -197,11 +197,16 @@ wxTB_DOCKABLE = wxc.wxTB_DOCKABLE
wxCOLOURED = wxc.wxCOLOURED wxCOLOURED = wxc.wxCOLOURED
wxFIXED_LENGTH = wxc.wxFIXED_LENGTH wxFIXED_LENGTH = wxc.wxFIXED_LENGTH
wxALIGN_LEFT = wxc.wxALIGN_LEFT wxALIGN_LEFT = wxc.wxALIGN_LEFT
wxALIGN_CENTER = wxc.wxALIGN_CENTER wxALIGN_CENTER_HORIZONTAL = wxc.wxALIGN_CENTER_HORIZONTAL
wxALIGN_CENTRE = wxc.wxALIGN_CENTRE wxALIGN_CENTRE_HORIZONTAL = wxc.wxALIGN_CENTRE_HORIZONTAL
wxALIGN_RIGHT = wxc.wxALIGN_RIGHT wxALIGN_RIGHT = wxc.wxALIGN_RIGHT
wxALIGN_BOTTOM = wxc.wxALIGN_BOTTOM wxALIGN_BOTTOM = wxc.wxALIGN_BOTTOM
wxALIGN_CENTER_VERTICAL = wxc.wxALIGN_CENTER_VERTICAL
wxALIGN_CENTRE_VERTICAL = wxc.wxALIGN_CENTRE_VERTICAL
wxALIGN_TOP = wxc.wxALIGN_TOP wxALIGN_TOP = wxc.wxALIGN_TOP
wxALIGN_CENTER = wxc.wxALIGN_CENTER
wxALIGN_CENTRE = wxc.wxALIGN_CENTRE
wxSHAPED = wxc.wxSHAPED
wxLB_NEEDED_SB = wxc.wxLB_NEEDED_SB wxLB_NEEDED_SB = wxc.wxLB_NEEDED_SB
wxLB_ALWAYS_SB = wxc.wxLB_ALWAYS_SB wxLB_ALWAYS_SB = wxc.wxLB_ALWAYS_SB
wxLB_SORT = wxc.wxLB_SORT wxLB_SORT = wxc.wxLB_SORT

View File

@@ -382,11 +382,13 @@ void wxPyCallback::EventThunker(wxEvent& event) {
wxPyCallbackHelper::wxPyCallbackHelper() { wxPyCallbackHelper::wxPyCallbackHelper() {
m_self = NULL; m_self = NULL;
m_lastFound = NULL; m_lastFound = NULL;
m_incRef = FALSE;
} }
wxPyCallbackHelper::~wxPyCallbackHelper() { wxPyCallbackHelper::~wxPyCallbackHelper() {
bool doSave = wxPyRestoreThread(); bool doSave = wxPyRestoreThread();
if (m_incRef)
Py_XDECREF(m_self); Py_XDECREF(m_self);
wxPySaveThread(doSave); wxPySaveThread(doSave);
} }
@@ -401,6 +403,7 @@ wxPyCallbackHelper::wxPyCallbackHelper(const wxPyCallbackHelper& other) {
void wxPyCallbackHelper::setSelf(PyObject* self, int incref) { void wxPyCallbackHelper::setSelf(PyObject* self, int incref) {
m_self = self; m_self = self;
m_incRef = incref;
if (incref) if (incref)
Py_INCREF(m_self); Py_INCREF(m_self);
} }

View File

@@ -179,6 +179,7 @@ public:
private: private:
PyObject* m_self; PyObject* m_self;
PyObject* m_lastFound; PyObject* m_lastFound;
int m_incRef;
}; };