On Tue, 14 Feb 2023 16:03:52 GMT, John Hendrikx <[email protected]> wrote:
>> This contains the following:
>> - Nested changes or invalidations using ExpressionHelper are delayed until
>> the current emission completes
>> - This fixes odd change events being produced (with incorrect oldValue)
>> - Also fixes a bug in ExpressionHelper where a nested change would unlock
>> the listener list early, which could cause a
>> `ConcurrentModificationException` if a nested change was combined with a
>> remove/add listener call
>> - A test for ExpressionHelper to verify the new behavior
>> - A test for all *Property and *Binding classes that verifies correct
>> listener behavior at the API level (this tests gets 85% coverage on
>> ExpressionHelper on its own, the only thing it is not testing is the locking
>> behavior, which is not relevant at the API level).
>> - A fix for `WebColorFieldSkin` which triggered a nested change which used a
>> flag to prevent an event loop (I've changed it now to match how
>> `DoubleFieldSkin` and `IntegerFieldSkin` do it
>
> John Hendrikx has updated the pull request incrementally with two additional
> commits since the last revision:
>
> - Fix javadoc link
> - Update doc
modules/javafx.base/src/main/java/javafx/beans/value/ChangeListener.java line
57:
> 55: * differs from a call to {@link ObservableValue#getValue}. All
> listeners are
> 56: * then notified again with an old value equal to the initial new
> value,
> 57: * and a new value with the latest value.
This seems like a right place.
It is still a bad practice to change the value in this method, so I would
recommend to keep the warning.
I did little rewording, please check how does this look:
* In general, it is considered a bad practice to modify the observed value in
* this method. But if still modified, then the notifications for this change
* are deferred until all the listeners are notified of current change.
* This results in a minor inconsistency of new value with the listeners
* that are still pending to be notified of current change that the listeners
* would receive a new value that differs from a call to {@link
ObservableValue#getValue}.
-------------
PR: https://git.openjdk.org/jfx/pull/837