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

Prasanta Sadhukhan psadhukhan at openjdk.org
Mon Jul 1 09:11:21 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 two additional commits since the last revision:

 - Test added
 - Test added

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

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

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

  Stats: 121 lines in 1 file changed: 121 ins; 0 del; 0 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