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.

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - Reset the index of the pile to be extra safe. After a refresh, we can not 
trust them, so even though this should not happen, if it can, we will not 
suffer from it
 - 8394617: TableView.refresh() leaves stale cells in the VirtualFlow pile 
which show old content when scrolled into view

Changes: https://git.openjdk.org/jfx/pull/2347/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=2347&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8394617
  Stats: 69 lines in 2 files changed: 69 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jfx/pull/2347.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/2347/head:pull/2347

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

Reply via email to