JDK-8247576 : Labeled/SkinBase: misbehavior on switching skin
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: openjfx14
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-06-15
  • Updated: 2022-09-09
  • Resolved: 2020-12-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx16Fixed
Related Reports
Blocks :  
Relates :  
Description
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

Comments
Changeset: 00a8646c Author: Jeanette Winzenburg <fastegal@openjdk.org> Date: 2020-12-07 13:06:35 +0000 URL: https://git.openjdk.java.net/jfx/commit/00a8646c
07-12-2020