RFR: 8349091: Charts: exception initializing in a background thread [v6]
Andy Goryachev
angorya at openjdk.org
Mon Mar 3 20:01:04 UTC 2025
On Fri, 28 Feb 2025 18:34:31 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> modules/javafx.controls/src/main/java/javafx/scene/chart/Chart.java line 561:
>>
>>> 559: accessibilityActive = winProp; // keep the reference so it won't get gc
>>> 560:
>>> 561: // lambda cannot be used in place of a ChangeListener in removeListener()
>>
>> Why not use a Subscription then? It seems tailor-made for what you are trying to do.
>
> I don't know how to use Subscription in this case.
> This does not work:
>
>
> ObservableValue<Window> winProp = sceneProperty().flatMap(Scene::windowProperty);
> accessibilityActive = winProp; // keep the reference so it won't get gc
> Subscription sub = winProp.subscribe((win) -> {
> if (win != null) {
> if (accessibilityActive == winProp) {
> accessibilityActive = null;
> }
> if (isAccessibilityActive()) {
> handleAccessibilityActive(true);
> }
> //winProp.removeListener(this);
> sub.unsubscribe(); <-- COMPILE ERROR
> }
> });
@hjohn could you help here please? How could we use Subscription in a situation when it has to be unsubscribed from within the lambda?
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1697#discussion_r1978113628
More information about the openjfx-dev
mailing list