RFR: 8244234: MenuButton: NPE on removing from scene with open popup
Ajit Ghaisas
aghaisas at openjdk.java.net
Mon Jan 17 15:16:30 UTC 2022
On Tue, 11 Jan 2022 14:42:19 GMT, eduardsdv <duke at openjdk.java.net> wrote:
> The NPE occurs when the skinnable is removed from the scene while the popup is showing.
> The MenuButtonSkinBase, when popup becomes hidden, tries to remove Mnemonics from the scene and runs into NPE.
> To avoid NPE a null-check is added to the 'showing' listener.
>
> Since the mnemonics cannot be removed from the scene in standard way, when popup becomes hidden.
> They are now also removed from the scene, when the skinnable is removed from it.
The fix looks OK, but, a few cleanups are required.
modules/javafx.controls/src/main/java/javafx/scene/control/skin/MenuButtonSkinBase.java line 157:
> 155:
> 156: // We only need to remove the mnemonics from the old scene,
> 157: // they will be added to the new one as soon as the pop becomes visible again.
typo : pop --> popup
modules/javafx.controls/src/main/java/javafx/scene/control/skin/MenuButtonSkinBase.java line 250:
> 248: @Override protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
> 249: return leftInset
> 250: + label.minWidth(height)
Unintended spacing changes are there in computePrefHeight, computePrefWidth, computeMinHeight and computeMinWidth methods. Please revert these unrelated spacing changes.
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/MenuButtonSkinBaseTest.java line 1:
> 1: package test.javafx.scene.control.skin;
Please add the missing copyright header.
-------------
PR: https://git.openjdk.java.net/jfx/pull/713
More information about the openjfx-dev
mailing list