RFR: JDK-8325402: TreeTableRow updateItem() does not check item with isItemChanged(..) unlike all other cell implementations
Marius Hanl
mhanl at openjdk.org
Wed Feb 14 20:52:02 UTC 2024
On Wed, 14 Feb 2024 19:25:27 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> `TreeTableRow` does not check the item with `isItemChanged(..)`, unlike all other implementations of the cell.
>>
>> This also means that the `TreeTableRow` always updates the item, although it should not, resulting in a performance loss as a `TreeTableRow` will always call `updateItem(..)`.
>>
>> It looks like that this was forgotten in [JDK-8092593](https://bugs.openjdk.org/browse/JDK-8092593).
>>
>> Checking the whole history, it looks like the following was happening:
>> 1. There was a check if the item is the same in all cell implementations (with `.equals(..)`)
>> 2. Check was removed as it caused bugs
>> 3. Check was readded, but instead we first check the index (same index) and then if we also have the same item (this time with `.isItemChanged(..)`, to allow developers to subclass it)
>> 4. Forgotten for `TreeTableRow` inbetween this chaos.
>>
>> Added many tests for the case where an item should be changed and where it should not.
>> Improved existing tests as well. Using `stageLoader`, as before the tests only created a stage when doing the assert.
>>
>> NOTE: The update logic is now the same as for all other 5 cell implementations. Especially `TreeCell` (since it is for a tree structure as well).
>
> modules/javafx.controls/src/main/java/javafx/scene/control/TreeTableRow.java line 424:
>
>> 422: // proceed with the code following this, so that we may
>> 423: // still update references, listeners, etc as required.
>> 424: break outer;
>
> I understand neither the comment nor this `break outer;`: there is no code that follows `outer: if`, so we might as well `return`, right?
Yes! I did it this way to be consistent with all other cell implementations. I really think that this should be refactored, I can also create a ticket for this. My preference would be to be consistent now, but change it for all cell implementations in one go.
What is your opinion?
> modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeTableViewTest.java line 1777:
>
>> 1775: }
>> 1776:
>> 1777: @Test public void testSetChildrenShouldUpdateTheCells() {
>
> we probably should have `@Test` on its own line
sure, just copied from above.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1360#discussion_r1490048165
PR Review Comment: https://git.openjdk.org/jfx/pull/1360#discussion_r1490049249
More information about the openjfx-dev
mailing list