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