Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8175358

Memory leak when moving MenuButton into another Scene

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      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 ----------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              aghaisas Ajit Ghaisas
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: