Regression bug in TreeView.getSelectionModel().getSelectedItem()
Abu Abdullah
falcon.sheep at gmail.com
Wed Apr 1 11:37:53 UTC 2020
On Wed, Apr 1, 2020 at 2:05 PM Dirk Lemmermann <dlemmermann at gmail.com>
wrote:
> You are listening to the changes made to the “list" of selected items but
> then you are using the “selectedItem” property. If the list gets updated
> BEFORE the “selectedItem” value was set then your code will fail. Adding to
> the list and setting the property is not an atomic operation.
>
> If this worked before then you were simply lucky. Newer versions of JavaFX
> might have rearranged the sequence of updates which causes this
> “regression”. But I think those were allowed changes. There is no contract
> that says that the “selectedItem” needs to be set before the list gets
> updated.
>
> Or am I missing something?
>
Thank you for your response, certainly the list is not updated between the
2 calls. it just works all the time in older version but not once in newer
version.
But I forgot very important condition. clicking normally on the tree just
works fine (correct behavior) in all versions in the same way. the one that
is not working is when programmatically select a tree node using:
*************************
tree.getSelectionModel().clearSelection();
tree.getSelectionModel().select(node);
final int row = tree.getRow(node);
tree.scrollTo(row);
*************************
More information about the openjfx-discuss
mailing list