RFR: 8187145: (Tree)TableView with null selectionModel: throws NPE on sorting [v5]

Andy Goryachev angorya at openjdk.org
Thu Nov 3 16:27:14 UTC 2022


On Thu, 3 Nov 2022 16:17:09 GMT, Ajit Ghaisas <aghaisas at openjdk.org> wrote:

>> it's not: `isAlreadySelected` is set on line 278 or 280.  Line 274 is just a declaration.
>
> What I mean by code simplification is -
> 
>         boolean isAlreadySelected = false;
>         MultipleSelectionModel<?> sm = getSelectionModel();
>         if (sm != null) {
>             isAlreadySelected = sm.isSelected(index);
> 
>             if (isAlreadySelected && shortcutDown) {
>                 sm.clearSelection(index);
>                 getFocusModel().focus(index);
>                 isAlreadySelected = false;
>             } else {
>                 sm.clearAndSelect(index);
>             }
>         }

in this version, there are code paths where you assign the same variable twice.  I don't do that, I don't like doing that.  Is this required or in the code style?

-------------

PR: https://git.openjdk.org/jfx/pull/876


More information about the openjfx-dev mailing list