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

PopupControl.skin.setSkin(Skin) fails to call dispose() on discarded Skin

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • jfx23
    • jfx21
    • javafx
    • None
    • b03
    • generic
    • generic

      PopupControl.skin.setSkin(Skin) discards a new Skin of the same class as the existing Skin, but fails to call Skin.dispose(). That fails to perform the cleanup the discarded Skin's dispose() method should have done.

      This issue is the same as JDK-8276056 but for PopupControl.

      EXAMPLE:
      Note that 'DISPOSE CALLED' is never printed and 'popupControl.getSkin() == skin2' does not evaluate to true, although we would expect it.

      import javafx.application.Application;
      import javafx.scene.Node;
      import javafx.scene.control.PopupControl;
      import javafx.scene.control.Skin;
      import javafx.stage.Stage;

      public class SkinBug extends Application {

          @Override
          public void start(Stage stage) {
              PopupControl popupControl = new PopupControl();

              CustomSkin skin1 = new CustomSkin();
              popupControl.setSkin(skin1);

              CustomSkin skin2 = new CustomSkin();
              popupControl.setSkin(skin2);

              System.out.println(popupControl.getSkin() == skin2);
          }

          public static void main(String[] args) {
              launch(args);
          }

          private class CustomSkin implements Skin<PopupControl> {

              @Override
              public PopupControl getSkinnable() {
                  return null;
              }

              @Override
              public Node getNode() {
                  return null;
              }

              @Override
              public void dispose() {
                  System.out.println("DISPOSE CALLED");
              }
          }

      }

            mhanl Marius Hanl
            mhanl Marius Hanl
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: