RFR: 8319779: SystemMenu: memory leak due to listener never being removed [v11]
Kevin Rushforth
kcr at openjdk.org
Tue Mar 5 22:21:53 UTC 2024
On Tue, 5 Mar 2024 08:20:03 GMT, Johan Vos <jvos at openjdk.org> wrote:
>> A listener was added but never removed.
>> This patch removes the listener when the menu it links to is cleared. Fix for https://bugs.openjdk.org/browse/JDK-8319779
>
> Johan Vos has updated the pull request incrementally with one additional commit since the last revision:
>
> Update modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/GlassSystemMenu.java
>
> Co-authored-by: John Hendrikx <john.hendrikx+github at gmail.com>
Answering my own questions...
The existing for loop quoted above actually loops while `>= 1` rather than `>= 0`:
for (int index = existingSize - 1; index >= 1; index--) {
so indeed the last menu would be held.
And I think that the answer to my other question (why is this even being used on Linux) is that the `createAndRefocusMenuBarStage()` method in the newly added test is calling `GlassSystemMenuBar::createMenuBar` unconditionally (via the Shim), when the actual logic in WindowStage qualifies by whether or not system menu is supported (which it only is for Mac).
So I think this is a test bug. I might recommend adding something like the following to the test:
assumeTrue(glassSystemMenu.isSupported());
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1283#issuecomment-1979732823
More information about the openjfx-dev
mailing list