Re: [gtk-list] Re: find_row_from_data issue in Perl::Gtk



> 
> This problem is fixed in cvs now.
> 

Ok, this may be by design, but to me it makes the whole find_row_by_data pretty useless:

It only finds the data if you pass it the SAME reference to the data that was used with
set_row_data()

In other words, say you build a list ... you assign data to the rows (which is done by
passing set_row_data() a reference to the data)

Now, the ONLY way find_row_by_data() will find your row is if you pass it the SAME reference.

I can understand why this is, only the reference is getting stored on the row, not the actual data,
but let me show you why this (too me) is worthless.

In my application, I have a large CList of messages (From, Subject, Date, etc) and I have
background processes that go out and check e-mail and so forth.  When there is new
information to be added to the CList, the background process sets a samaphore file up,
and a Gtk::timeout event will see the file, and do a refresh on the CList...
I don't want it to clear the selection however, so here is how I was GOING to do it:

I was going to go through CList->selection() and create an array of CList->get_row_data()
elements.  This would give me a list of the selected items (or a list of the "Row Data" of the
selected Items.  Which is a unique item identifier)  Then I do a CList->clear; and rebuild the
list.
Once the list was rebuilt, I was going to go through my array of "Row Data" items, and
do a CList->find_row_by_data() on each one, and then CList->select_row() in the found
rows.
Now some rows may be gone, as the even that triggered the refresh may have been a delete
event. Who knows?  But I check for -1 to be returned by find_row_by_data() so if the
row doesn't exist anymore, no big deal.

Of course, this doesn't work.  Because the REAL data is not stored with the rows, just the
reference to the data, and when you call CList->clear, that gets destroyed, and when
you build the list again, you are assigning all new references, and find_row_from_data()
only compares the reference, it doesn't de-reference it and compare the actual data
(which is what I think it SHOULD do, but thats just me)

I just decided not to use it at all, and went about the thing in a whole different way...

But anyway, I guess my question is, shouldn't find_row_by_data() derefernce the reference and
compare the actual data, instead of just comparing references?

-Steve



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