On Fri, 16 Oct 2026 17:45:24 GMT, Marius Hanl <[email protected]> wrote:

> This PR fixes a regression from https://github.com/openjdk/jfx/pull/1830.
> 
> My suspicion was that this might be a preexisting after all, which just 
> happens to be much more easily to reproduce with `refresh()`.
> Turns out I was right, it could already happen before, without `refresh` 
> involved.
> So I wrote a second test for that scenario. 
> 
> Both tests (and the bug of course) are fixed when we always clear the index 
> of the cells that will land in the pile and to be removed from the viewport.
> This ensures that we will always update a cell we use from the pile. 
> 
> The reuse of the cells when scrolling a bit is unaffected. 
> Example: When we show 10 cells, scroll a bit down so that the first 3 items 
> are not visible anymore, we will still reuse the cells with index 3 - 9, and 
> update the other 3 cells with their new index 10,11,12. Nothing changed here. 
> If we now change the height so that cell index 12 is not visible anymore, it 
> will land in the pile and will get the index `-1`.
> 
> ---
> 
> Another advantage: Cells in the pile will not have a reference to their item 
> anymore. Cells can be in the pile forever, e.g. because the user change the 
> height of the application.
> 
> This might come in handy for 
> [JDK-8390878](https://bugs.openjdk.org/browse/JDK-8390878) as well.
> 
> ---
> 
> Note: I still decided to also the `resetIndex` call for the pile in my second 
> commit. It is not needed to fix the bug, but it makes sense. When we are 
> rebuilding the `VirtualFlow`, we can and should not trust any cell. It 
> therefore makes sense to reset the index pf pile cells here as well.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This pull request has now been integrated.

Changeset: 71efad70
Author:    Marius Hanl <[email protected]>
URL:       
https://git.openjdk.org/jfx/commit/71efad7078a6df08317cceb5786b5be13623adc0
Stats:     95 lines in 2 files changed: 71 ins; 11 del; 13 mod

8394617: TableView.refresh() leaves stale cells in the VirtualFlow pile which 
show old content when scrolled into view

Reviewed-by: angorya, jhendrikx

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

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

Reply via email to