RFR: 8252863: Spinner keeps spinning if removed from Scene
Kevin Rushforth
kcr at openjdk.org
Fri Dec 16 01:52:12 UTC 2022
On Fri, 16 Dec 2022 00:57:00 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> Spinner was not stopping because it was getting removed from scene before the mouse release event handler was getting invoked.
>>
>> Added listener for `sceneProperty` so that when Spinner is removed from the scene, `stopSpinning` method shall be called.
>>
>> Added unit test to validate the fix
>
> modules/javafx.controls/src/main/java/javafx/scene/control/skin/SpinnerSkin.java line 254:
>
>> 252: }));
>> 253:
>> 254: getSkinnable().sceneProperty().addListener((observable, oldValue, newValue) -> {
>
> this will permanently add a listener on the control's scene property, creating a memory leak when skins are replaced.
> You probably want to use the newly introduced ListenerHelper (there is an instance of it right there in the constructor):
>
> lh.addChangeListener(control.sceneProperty(), (x) -> {
> behavior.stopSpinning();
> });
>
>
> doing this will decouple the listener on Skin.dispose()
Yes, and the failing unit tests show exactly this leak.
-------------
PR: https://git.openjdk.org/jfx/pull/976
More information about the openjfx-dev
mailing list