RFR: 8088594: NullPointerException on showing submenu of a contextmenu [v3]

Andy Goryachev angorya at openjdk.org
Tue Apr 11 15:15:51 UTC 2023


On Tue, 11 Apr 2023 12:18:52 GMT, Karthik P K <kpk at openjdk.org> wrote:

>> When custom skin was loaded, the listeners added in `ContextMenuContent` class while loading the default skin were not removed. This was causing the NPE when outdated listeners were invoked.
>> 
>> Updated the code to dispose listeners in the `dispose` method of `ContextMenuSkin` so that when new skin is loaded, listeners added in the old skin are removed.
>> 
>> Added system test to validate the fix.
>
> Karthik P K has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Add space between if and (
>  - Address review comments

modules/javafx.controls/src/main/java/javafx/scene/control/skin/ContextMenuSkin.java line 206:

> 204:         if (root instanceof ContextMenuContent) {
> 205:             ((ContextMenuContent)root).disposeListeners();
> 206:         }

We could use


        if (root instanceof ContextMenuContent cm) {
            cm.disposeListeners();
        }


pattern

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1082#discussion_r1162960698


More information about the openjfx-dev mailing list