FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
I'm still able to reproduce the issue using 9-ea+155.
To simplify the setup I have written a new test case that removes a MenuButton from the scene, but the accelerator on the item is still active.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.MenuButton;
import javafx.scene.control.MenuItem;
import javafx.scene.input.KeyCombination;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class MenuButtonMemoryLeakTest extends Application {
@Override
public void start(Stage stage) throws Exception {
VBox vbox = new VBox();
// create MenuButton having one item
MenuButton menuButton = new MenuButton();
MenuItem item = new MenuItem();
item.setAccelerator(KeyCombination.keyCombination("Ctrl+T"));
item.setOnAction(e -> new Alert(AlertType.INFORMATION, "Hello from removed menu item").showAndWait());
menuButton.getItems().add(item);
// add a button to remove the MenuButton
Button button = new Button("Click me");
button.setOnAction(e -> {
vbox.getChildren().setAll(new Label("MenuButton removed. Now press Ctrl-T"));
});
vbox.getChildren().addAll(button, menuButton);
Scene scene = new Scene(vbox, 300, 100);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) throws Exception {
Application.launch(args);
}
}
---------- END SOURCE ----------
A DESCRIPTION OF THE PROBLEM :
I'm still able to reproduce the issue using 9-ea+155.
To simplify the setup I have written a new test case that removes a MenuButton from the scene, but the accelerator on the item is still active.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.MenuButton;
import javafx.scene.control.MenuItem;
import javafx.scene.input.KeyCombination;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class MenuButtonMemoryLeakTest extends Application {
@Override
public void start(Stage stage) throws Exception {
VBox vbox = new VBox();
// create MenuButton having one item
MenuButton menuButton = new MenuButton();
MenuItem item = new MenuItem();
item.setAccelerator(KeyCombination.keyCombination("Ctrl+T"));
item.setOnAction(e -> new Alert(AlertType.INFORMATION, "Hello from removed menu item").showAndWait());
menuButton.getItems().add(item);
// add a button to remove the MenuButton
Button button = new Button("Click me");
button.setOnAction(e -> {
vbox.getChildren().setAll(new Label("MenuButton removed. Now press Ctrl-T"));
});
vbox.getChildren().addAll(button, menuButton);
Scene scene = new Scene(vbox, 300, 100);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) throws Exception {
Application.launch(args);
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8244075 Accelerator of ContextMenu's MenuItem is not removed when ContextMenu is removed from Scene
- Resolved
-
JDK-8244110 NPE in MenuButtonSkinBase change listener
- Resolved
-
JDK-8244081 Memory leak in MenuButtonSkinBase as control.sceneProperty() listener is not removed
- Closed
-
JDK-8146256 Memory leak when moving MenuButton into another Scene
- Closed
(1 links to)