RFR: 8319779: SystemMenu: memory leak due to listener never being removed [v10]

Kevin Rushforth kcr at openjdk.org
Tue Mar 5 21:49:50 UTC 2024


On Fri, 1 Mar 2024 14:55:58 GMT, Johan Vos <jvos at openjdk.org> wrote:

> The failure on Linux has an interesting cause. The GlassSystemMenu (in com.sun.javafx.tk.quantum) has this code:
> 
> ```
>             /*
>              * Leave the Apple menu in place
>              */
>             for (int index = existingSize - 1; index >= 0; index--) {
>                 Menu menu = existingMenus.get(index);
>                 clearMenu(menu);
>                 glassSystemMenuBar.remove(index);
>             }
> ```
> 
> As a consequence, the first menu is not cleared -- regardless of the presence of an apple or not. There are plenty quick and dirty ways to fix this, but this platform-specific check probably does not belong in this package. @kevinrushforth what do you prefer to do in cases like these?

I missed responding to this. Presuming this really does need to be different on Mac than on other platforms, I guess the cleanest thing would be to move that logic to a method that can be overridden on Mac. If that's not feasible, then checking PlatformUtil.isMac() would be the other way.

One question, though: Why does this prevent the first menu from being cleared? Unless I'm missing something, doesn't that loop cover the whole range of menus? And since Linux doesn't even implement system menus, I wonder why this code is active for Linux at all?

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

PR Comment: https://git.openjdk.org/jfx/pull/1283#issuecomment-1979690977


More information about the openjfx-dev mailing list