RFR: 8252863: Spinner keeps spinning if removed from Scene [v2]

Karthik P K kpk at openjdk.org
Fri Dec 16 05:11:11 UTC 2022


On Fri, 16 Dec 2022 01:49:12 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> 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.

Made changes to use `ListenereHelper` instead of permanently adding listener on control's `sceneProperty`. Please check.

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

PR: https://git.openjdk.org/jfx/pull/976


More information about the openjfx-dev mailing list