[wxPython-users] Request to fix wx.ListCtrl.SetItemData()

Jorgen Bodde jorgen.maillist at gmail.com
Wed May 9 04:15:09 PDT 2007


Ok I see Vadim is on it.

Unfortunately they cannot break binary compatibility so thet are
thinking of adding another method there which will allow the same
functionality as wxControlWithItems::SetClientData... it's not first
price, but in this case the second price is more then welcome :-)

- Jorgen

On 5/9/07, Jorgen Bodde <jorgen.maillist at gmail.com> wrote:
> Hi Robin,
>
> I think the wxWidgets c++ guys will not change the API easliy, but I
> can start a discussion there to see what can be done, and why on earth
> it was made an int to begin with.
>
> Thanks for the explanation!
>
> - Jorgen
>
> On 5/8/07, Robin Dunn <robin at alldunn.com> wrote:
> > Jorgen Bodde wrote:
> >
> > > 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 ;-)
> >
> > It does in wxPython.  Since the C++ class uses a class type to hold the
> > data instead of just a long int I am able to derive a Python-aware
> > subclass that does proper refcounting of the PyObject.  Then I replace
> > the SetClientData method with one that looks like this:
> >
> >          void SetClientData(int n, PyObject* clientData) {
> >              wxPyClientData* data = new wxPyClientData(clientData);
> >              self->SetClientObject(n, data);
> >          }
> >
> > The wxPyClientData increments the refcount in the constructor and
> > decrements it in the destructor.  Since wxControlWithItems takes
> > ownership of the data object then I know that it will eventually be
> > destroyed properly, either when the item is removed from the control or
> > when the control is destroyed, so I don't have to worry about it.  If
> > wxListCtrl was changed to also use wxClientData then it would take about
> > five minutes to allow wxPython to do the same thing there too.
> >
> > --
> > 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