ValidatorFX icon indicating copy to clipboard operation
ValidatorFX copied to clipboard

WeakListener regression

Open effad opened this issue 2 months ago • 2 comments

net.synedra.validatorfx.GraphicDecoration.layoutListener ist created like this:

		layoutListener = new WeakChangeListener<>((observable, oldValue, newValue) -> layoutGraphic());

this is very likely wrong, since WeakChangeListener explicetly states that "You have to keep a reference to the {@code ChangeListener} that was passed in for as long as it is in use, otherwise it will be garbage collected too soon."

One way to reproduce the problem is to use the AccordionDemo:

  • Write Strings that are "too long" (e.g. 4 chars) into Pane 0 and Pane 1.
  • Open Pane 2
  • Trigger Garbage Collection (e.g. visualvm)
  • Open and close Pane 0 The red mark will be displayed on top of the closed Pane 0, assumedly because the weak listener is gone.

effad avatar Nov 04 '25 13:11 effad