RFR: 8354813: Parent.isNeedsLayout() may return wrong value in property listener

Andy Goryachev angorya at openjdk.org
Wed Apr 16 17:08:54 UTC 2025


On Wed, 16 Apr 2025 10:31:50 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

> A listener that is added to `Parent.needsLayoutProperty()` may see a wrong value when calling `Parent.isNeedsLayout()` from the callback. The fix is to apply the value before notifying the listeners.

modules/javafx.graphics/src/main/java/javafx/scene/Parent.java line 996:

> 994:         // Needs to be set before needsLayout is updated, as otherwise a listener that
> 995:         // calls isNeedsLayout() might see the old value.
> 996:         layoutFlag = flag;

This is the right change, but I suspect it might cause regression.

The JavaFX entities which call `isNeedsLayout()`:

`VirtualFlow::layoutChildren`
`VirtualFlow::setCellIndex`

We may need to focus on List/Table/Tree/TableViews during testing.

(Anecdata: I've seen continuous layout calls in the TableView before)

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1781#discussion_r2047370606


More information about the openjfx-dev mailing list