RFR: 8334593: Adding, removing and then adding a JFXPanel again leads to NullPointerException [v3]
Andy Goryachev
angorya at openjdk.org
Mon Jul 1 20:46:22 UTC 2024
On Mon, 1 Jul 2024 09:16:52 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> 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
Kevin is right, this fix does not solve the issue mentioned in the ticket. Once the fxPanel is added back, its content is not visible. Does not matter whether removing/adding happens at startup or the button event handler.
(attaching a slightly modified test case to the ticket, notice lines 30 and 44.
Also, I think swing requires validate() and repaint() called after modifying the component's children.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1493#issuecomment-2200985904
More information about the openjfx-dev
mailing list