RFR: 8334593: Adding, removing and then adding a JFXPanel again leads to NullPointerException [v3]

Prasanta Sadhukhan psadhukhan at openjdk.org
Mon Jul 1 09:16:52 UTC 2024


> Adding, then removing, and then adding a JFXPanel to the same component in the Swing scene graph leads to a NullPointerException in GlassScene because the sceneState is null.
> Removing JFXPanel calls JFXPanel.removeNotify which calls Window.hide which calls SceneHelper.disposePeer -> Scene.disposePeer -> EmbeddedScene.dispose -> GlassScene.dispose which sets "sceneState" to null...
> so when GlassScene.updateSceneState is called, it results in NPE.
> Fix is to check if `host` (which is usually javafx.embed.swing.JFXPanel$HostContainer for active JFXPanel) has been reset/deleted which is done when `EmbeddedScene.dispose` is called during removeNotify and abstain from updating the scene state

Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:

  Test fix

-------------

Changes:
  - all: https://git.openjdk.org/jfx/pull/1493/files
  - new: https://git.openjdk.org/jfx/pull/1493/files/6ddb5ab3..2872159b

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jfx&pr=1493&range=02
 - incr: https://webrevs.openjdk.org/?repo=jfx&pr=1493&range=01-02

  Stats: 6 lines in 1 file changed: 1 ins; 2 del; 3 mod
  Patch: https://git.openjdk.org/jfx/pull/1493.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1493/head:pull/1493

PR: https://git.openjdk.org/jfx/pull/1493


More information about the openjfx-dev mailing list