RFR: 8283509: Invisible menus can lead to IndexOutOfBoundsException
Ajit Ghaisas
aghaisas at openjdk.java.net
Wed Mar 30 04:51:45 UTC 2022
On Tue, 29 Mar 2022 12:11:54 GMT, Robert Lichtenberger <rlichten at openjdk.org> wrote:
> > Have you considered keeping the same while loop in findSibling() method and skipping invisible Menus in it? This is to avoid creating and traversing a new list.
>
> This would not give the correct result. findSibling must return the index in the list of **visible** menus, since this is what setFocusedMenuIndex() really expects. If we only skip invisible menus we will possibly return an index that is out of bounds, which is exactly what this bug is about.
OK. Thanks for the explanation.
The fix and the test looks good.
Only one minor correction needed is in comment.
`// Traverse all menus in menubar to find nextIndex`
should be
`// Traverse all visible menus in menubar to find nextIndex`
-------------
PR: https://git.openjdk.java.net/jfx/pull/759
More information about the openjfx-dev
mailing list