Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8344067

TableCell indices may not match the TableRow index

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • jfx24
    • jfx23, jfx24
    • javafx
    • None
    • b18
    • generic
    • generic

      Under some circumstances, it is possible that the TableCell indices do not match with their TableRow index.

      This does not happen often, but there is a scenario where it can be reproduced 100%.

      Check the attached source.
      1. Start the App
      2. Scroll to the bottom (completely)
      3. Now click the 'Re-Set items' Button
      4. Note that you can not select LASTITEM anymore, when you click on the cell (so inbetween the column bounds)
      5. The "0" item can be selected

      The following happens under the hood:
      - We scroll to the bottom, the last TableRow has the index 60, the underlying TableCells as well
      - Now we re-set the Items, there is one item that is in the previous items list and in the new one
      - JavaFX will now reindex all cells since the items completely changed
      - The TableRow with index 60 will now get the index 1. This does not trigger an update of the underlying TableCells.
      - The TableRow will now also update the Item. The Item is in this case the SAME ("LASTITEM" before, "LASTITEM" after)
      -> This will therefore not trigger the cell update, so the underlying TableCells will not update the index ever (they still think they are at index 60)

      This behavior is deterministic, but is hard to reproduce other than my example since we need to be 'lucky' that the cell is reused exactly where the item is the same as before, just the index changed.

      NOTE: applies to TableView and TreeTableView.

            mhanl Marius Hanl
            mhanl Marius Hanl
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: