RFR: 8265206: Tree-/TableCell: editing state not updated on cell re-use

Johan Vos jvos at openjdk.java.net
Wed Apr 21 17:56:36 UTC 2021


On Wed, 21 Apr 2021 14:37:15 GMT, Jeanette Winzenburg <fastegal at openjdk.org> wrote:

>> modules/javafx.controls/src/main/java/javafx/scene/control/TableCell.java line 581:
>> 
>>> 579:         // so that subclasses which override cancelEdit can execute. So,
>>> 580:         // I have to use a kind of hacky flag workaround.
>>> 581:         updateEditingIndex = false;
>> 
>> Do you need to assert on updateEditingIndex being true before this is done?
>
> hmm .. don't quite understand your comment: it's a flag to tell cancelEdit to not update control's editing state (that whole block is simply extracted from the pre-fix state .. where it has been for ages ;) So the answer is most probably no :)

I see the updateEditingIndex is used as a hacky flag as the comment says, and `table.edit(-1, null)` is called conditionally.
But my question is about the pre- and postconditions. What would happen if a subclass overrides `cancelEdit` and throws an exception, so that `updateEditingIndex = true` is not called after the `cancelEdit`? In that case, `updateEditingIndex` stays false.
I'm not saying this is an issue, just wondering about this as this flag does an important thing -- and I do know this was in the code before the PR, so the PR is definitely an improvement, I'm just thinking that this might be an opportunity to deal with the precondition that updateEditingIndex *should* be true when entering the method and false when leaving the method.

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

PR: https://git.openjdk.java.net/jfx/pull/473


More information about the openjfx-dev mailing list