RFR: 8252863: Spinner keeps spinning if removed from Scene
Andy Goryachev
angorya at openjdk.org
Fri Dec 16 01:02:12 UTC 2022
On Thu, 15 Dec 2022 14:23:57 GMT, Karthik P K <kpk 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
also, this change should trigger a failure in SkinMemoryLeakTest.
I see the checks are failing.
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()
-------------
Changes requested by angorya (Committer).
PR: https://git.openjdk.org/jfx/pull/976
More information about the openjfx-dev
mailing list