palexdev/MaterialFX

Problems with changing skins at runtime

Ibrahim-Rashwan opened this issue · 1 comments

Describe the bug
When changing the default skin to a custom one the old one doesn't remove the addedListener on disposal resulting in problems like NullPointerException like:

  • The MFXFilterPaneSkin has a listener on MFXFilterPane active filters if i change the default skin the old one keeps the listener trying to access the contained filterPane which is null from the SkinBase.dispose() method.

To Reproduce
Steps to reproduce the behavior:

  1. Call MFXDialog.filter(filterPane) to make a filter dialog.
  2. Call MFXFilterPane.setSkin(CustomFilterPaneSkin) to change the used filterPane's default skin.
  3. Add some filters to the used filterPane so you can add a filter throught GUI.
  4. Run and try to add a filter.
  5. Prints a NullPointerException from the old MFXFilterPaneSkin (the that has changed and disposed) that the contained filterPane is null (because it has been set to null from the parent[SkinBase.dispose()] method).

Expected behavior
No errors printed

SOLUTION
Each skin should override dispose() to call super.dispose() and remove any added listeners for the disposal to happen correctly (if the skin is disposed you should never worry about it anymore it should no longer be in memory [which is not the case for some reason]).

Fixed in version 11.17.0