Bela Babik wrote:> Created a bug report:
>
http://rubyforge.org/tracker/index.php?func=detail&aid=13676&group_id=35&atid=218
>
>
From Bug Report:
> I don''t know how it supposed to work, but it seems that the ruby
object is converted to long and then back (ListCtrl.i):
> VALUE get_item_data(int row)
> {
> if ( row < 0 || row >= self->GetItemCount() ) return Qnil;
> long item_data = self->GetItemData(row);
> if ( item_data == 0 ) return Qnil;
> return (VALUE)item_data;
> }
>
> VALUE set_item_data(int row, VALUE ruby_obj)
> {
> if ( row < 0 || row >= self->GetItemCount() )
> {
> rb_raise(rb_eIndexError, "Uninitialized item");
> }
> long item_data = (long) ruby_obj;
> bool result = self->SetItemData(row, item_data);
> if ( result )
> return Qtrue;
> return Qnil;
> }
>From this information you provided, I belive that the
wxListCtrl#set_item_data and wxListCtrl#get_item_data need a Integer based
value, and the way Alex has interpreted this to work, is to convert the Ruby
Object into a pointer to it, so that the data can be saved to the
wxListCtrlItem, and then later retrived via converting the pointer back into a
Ruby Object, and returning the value of it. However, all that is being
returned, is either nil, or corrupt data.
There is two options for this. One option, is to correct the way set_item_data
and get_item_data in the backend, /OR/ modify the Ruby Side of the Code, using a
class attribute for ListCtrlItem, to store the data in a hash, with the item
instance as the key, and the data as the value, and then overloading the
set_item_data/get_item_data to code that will simply set and fetch the data from
the hash. Just my two cents.
Also, sending this to the Development list to, so that way, it''s on
both lists.
Mario Steele