Regression bug in TreeView.getSelectionModel().getSelectedItem()
Dirk Lemmermann
dlemmermann at gmail.com
Wed Apr 1 10:05:11 UTC 2020
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?
Dirk
> On 1 Apr 2020, at 07:02, Abu Abdullah <falcon.sheep at gmail.com> wrote:
>
> Hi,
>
> I have old application on jfx bundled with oracle jdk 1.8 working fine.
>
> i have upgraded it to the latest jfx14 but found the following issue:
>
> TreeView.getSelectionModel().getSelectedItem() returns null eventhough that
> TreeView.getSelectionModel().getSelectedItems().size() = 1
>
> code is like:
> *********************************
> TreeView.getSelectionModel().getSelectedItems().
> addListener(new ListChangeListener<TreeItem<AudioInfo>>()
> {
> @Override
> public void onChanged(Change<? extends TreeItem<AudioInfo>> change)
> {
> int i = TreeView.getSelectionModel().getSelectedItems().size();
> // i =1
>
> TreeItem<AudioInfo> node = TreeView.getSelectionModel().getSelectedItem();
> // node = null
> }
> });
> ************************************
>
> in the bundled version of jfx, it was working as expected and im able to
> retrieve the object.
More information about the openjfx-discuss
mailing list