Forum: wxRuby ListCtrl.get_selections broken?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Phil Puccio (Guest)
on 2009-05-12 21:35
(Received via mailing list)
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
Phil P. (Guest)
on 2009-05-13 06:13
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
Alex F. (Guest)
on 2009-05-14 17:27
(Received via mailing list)
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 topic is locked and can not be replied to.