Re: Strange behaviour assigning values to a SimpleList




Daniel Flemming said:
I've found that if I assign the reference directly for the data list of a
SimpleList, it doesn't work correctly.

the value in the data key is a reference to a tied array, which uses tie()
magic to store the data in a Gtk2::ListStore.  you replaced that magical
reference with a non-magical reference, so no set magic happens and the
ListStore never gets populated.  that's just the way it works in perl when you
put a tied object into list or hash.


Incidentally, it'd be awfully nice if there was a method to update the
data in a SimpleList. Something like this:

$mySimpleList->new_data (@theArrayIWantDisplayed)

would just be unbelievably handy (and way more readable :).

see the pod for Gtk2::SimpleList, also at
http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/SimpleList.html :

   $slist->set_data_array (arrayref)
       Set the data in the list to the array reference arrayref. This is
       completely equivalent to @{$list->{data}} = @{$arrayref} and is
       only here for convenience and for those programmers who don?t like
       to type-cast and have static, set once data.

has been there since Gtk2-0.92.


-- 
muppet <scott at asofyet dot org>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]