[wxPython-users] Request to fix wx.ListCtrl.SetItemData()
Jorgen Bodde
jorgen.maillist at gmail.com
Mon May 7 23:58:19 PDT 2007
Hi Robin,
I see. So what we actually need is a marshalled object that functions
as a bridge between a PyObject and the C++ GUI. The marshaled object
will keep the refcount to at least one as long as it is assigned to
the wx.ListCtrl. Once a function is called like SetClientData /
DeleteItem or DeleteAllItems, the marshalled object will decrease the
refcount on the python object, and the garbage collector will destroy
it if no other classes point to the object.
Just a small question, is the SetClientData of wx.ControlWithItems
also unsafe? I keep my objects in a list anyway, so there is no danger
of being prematurely destroyed.. I come from a C++ background, so I am
used to cleaning up my own crap, and I know the SetClientData does not
keep a reference ;-)
Regards,
- Jorgen
On 5/7/07, Robin Dunn <robin at alldunn.com> wrote:
> Jorgen Bodde wrote:
> > Hi Robin,
> >
> > Thanks for the reply. I see what you mean. The
> > wxControlWithItems::SetClientData is a void* .. well AFAIK I long can
> > be safely casted to a void * .. I've done it many times, So maybe the
> > indirect pyobject -> void * -> long construction might be a solution
>
> There would still be the problem with knowing when to delete the object.
> The wxListCtrl won't do it since it just thinks that it as long
> integers. And if we try to do it in the wrapper code we'll surely
> either miss some cases, or possibly disrupt some user apps as we'll have
> to catch all the delete events ourselves.
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org Java give you jitters? Relax with wxPython!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>
More information about the wxpython-users
mailing list