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

Labeled/SkinBase: misbehavior on switching skin

XMLWordPrintable

      happens if it has a graphic. The misbehavior is

      - memory leak
      - NPE (after removing incorrect guard against null in the listener ;) on resize the graphic

      culprit is a listener added to the graphic's layoutBounds:

          final InvalidationListener graphicPropertyChangedListener = valueModel -> {
              invalidText = true;
              // fixme: this must not be called after dispose
              /*if (getSkinnable() != null)*/
                  getSkinnable().requestLayout();
          };

      to reproduce the memory leak, add a Label (and all other subclasses) with graphic to the list of controls in SkinMemoryLeakTest. For the NPE, add a test like:

          /**
           * Cleanup graphic listener -
           */
          @Test
          public void testLabeledGraphicDispose() {
              Rectangle graphic = (Rectangle) control.getGraphic();
              installDefaultSkin(control);
              control.getSkin().dispose();
              graphic.setWidth(500);
          }
          
       to fix, remove the listener in dispose

            fastegal Jeanette Winzenburg
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: