On Fri, 12 Nov 2021 23:42:30 GMT, Kevin Rushforth <[email protected]> wrote:
>> Florian Kirmaier has updated the pull request incrementally with one
>> additional commit since the last revision:
>>
>> 8274022
>> Simplified code related to WeakHashMaps
>
> modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/ControlAcceleratorSupport.java
> line 291:
>
>> 289: WeakReference<ChangeListener<KeyCombination>> listenerW
>> = changeListenerMap.get(menuitem);
>> 290: ChangeListener<KeyCombination> listener = listenerW ==
>> null ? null : listenerW.get();
>> 291: if (listener != null) {
>
> This will fail to remove a weak reference to a listener that has been
> collected. It is a `WeakHashMap`, so the `WeakReference` to the listener will
> be reclaimed as soon as the `menuItem` is no longer reachable, but if you
> used the same logic as you did for the scene listener (e.g., on lines
> 254-261), it would be removed sooner. I don't know whether it matters in this
> case.
Yes, you are right. I now use the same logic in all 3 places.
I guess it doesn't matter because the key always references the listener - but
the code is now more straight line.
-------------
PR: https://git.openjdk.java.net/jfx/pull/659