WeakXXListener - when not to use?

Pedro Duque Vieira pedro.duquevieira at gmail.com
Wed Mar 25 22:21:00 UTC 2020


Hi guys,

Sorry to barge in on the conversation but I think I have some comments that
might add to the conversation.

Sometime ago someone reported this bug in the JMetro issue tracker:
https://github.com/JFXtras/jfxtras-styles/issues/144 (it's a hobby project,
a JavaFX theme, I've been working on, on my spare time)

To summarize: they want to allow the user to be able to change themes while
the JavaFX app is running which will end up changing control skins on the
process. I think it's a valid scenario.

What I've found that is that the JavaFX Skins of some controls don't
release the listeners, in this case TextFieldSkin when the skin of the
corresponding control gets switched. Same for ProgressBarSkin  it seems. I
think in the dispose method of both skins the listeners that were added in
the skins should be removed?
So the old skin listeners end up being called, when they shouldn't because
the skin of the Control is now another object. This ends up in an Exception
being thrown in those listeners.

I think the reporter of the issue ended up registering an issue with this
in the JavaFX issue tracker.

Thanks. Which this adds something to the conversation.

Best regards,

-- 
Pedro Duque Vieira - https://www.pixelduke.com


More information about the openjfx-dev mailing list