Regression bug in TreeView.getSelectionModel().getSelectedItem()

Dirk Lemmermann dlemmermann at gmail.com
Wed Apr 1 12:02:24 UTC 2020


There is a difference between doing this programmatically or via interaction with the UI. But this is somewhat too low level for me and I hope somebody else can answer how and when observables are updated. I assume it has something to do with the pulse?

Dirk

> On 1 Apr 2020, at 13:37, Abu Abdullah <falcon.sheep at gmail.com> wrote:
> 
> On Wed, Apr 1, 2020 at 2:05 PM Dirk Lemmermann <dlemmermann at gmail.com <mailto: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