ListCtrl.get_selections broken?

Hi,

In a thread back in March, Alex F. provided a fix in one line of
ListCtrl.get_selections:

end
The only change is Wx::LIST_NEXT_ALL was previously LIST_NEXT_BELOW.

That fix got me past my initial problem, too, but then I found that if
I sent get_selections to a ListCtrl with only one row or with no rows
(I’m using report mode), the code would go into a loop and hang my
CPU. After changing the second reference of Wx::LIST_NEXT_BELOW to
Wx::LIST_NEXT_ALL, everything worked fine for me.

Alex, you might want to consider this additional change.

Thanks,

Phil

Sorry, my original posting omitted most of the method I was referring
to. The fixed method as originally posted by Alex was:

class Wx::ListCtrl
def get_selections
selections = []
item = get_next_item(-1, Wx::LIST_NEXT_ALL, Wx::LIST_STATE_SELECTED)
while item >= 0
selections << item
item = get_next_item(item, Wx::LIST_NEXT_BELOW,
Wx::LIST_STATE_SELECTED)
end
selections
end
end

My suggestion is that the second Wx::LIST_NEXT_BELOW be changed to
Wx::LIST_NEXT_ALL .

Phil

Phil Puccio wrote:

 selections << item
 item = get_next_item(item, Wx::LIST_NEXT_BELOW, Wx::LIST_STATE_SELECTED)

end
selections
end
end
The only change is Wx::LIST_NEXT_ALL was previously LIST_NEXT_BELOW.
That fix got me past my initial problem, too, but then I found that if I sent get_selections to a ListCtrl with only one row or with no rows (I’m using report mode), the code would go into a loop and hang my CPU. After changing the second reference of Wx::LIST_NEXT_BELOW to Wx::LIST_NEXT_ALL, everything worked fine for me.
Alex, you might want to consider this additional change.

Thanks very much Phil, I’ve committed this change to SVN

alex

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs