On Wed, 25 Mar 2026 15:36:45 GMT, Marius Hanl <[email protected]> wrote:
> > That is a good point. That branch of code is never executed in my > > application. However, I use the `DEFAULT_SORT_POLICY`, which itself is > > probably not atomic. If the user provides their own sort policy, all bets > > are off. > > I guess you are right. The code is very questionable. But ouf of scope. Feel > free to create a PR and maybe some tests, one with a custom sort policy / a > custom selection model (which seems to be a NOP for this code, still good to > test). I can create a ticket! I studied `TablePositionBase`. When the list is sorted, the list of selected cells changes. The identity of these items is dependent on their position, not the item in that position. See the hash implementation here: https://github.com/openjdk/jfx/blob/master/modules/javafx.controls/src/main/java/javafx/scene/control/TablePositionBase.java#L144 For example: consider the list `{B, A}`. If `A` is selected, the list of selected cells is `{1}`. After the sort, the new list is `{A, B}` and the list of selected cells is `{0}`. One item was removed, one item was added. We need to notify the listeners. If all the items were selected, i.e. with `selectAll`, `removed` will always be empty since the new and old selected cells will be the same. Given this information, I conclude it has nothing to do with whether the user is using a custom sort policy. You can only skip the check if a) there are no selected items (obviously), or b) all the items are selected. ------------- PR Comment: https://git.openjdk.org/jfx/pull/2100#issuecomment-4130898491
