On Fri, 28 Jun 2024 08:49:49 GMT, Prasanta Sadhukhan <psadhuk...@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

Check is not without precedence in this file..There are instance of  `assert 
host != null;` and `host != null` check like below
https://github.com/openjdk/jfx/blob/6a586b662592be3eb81670f0c5ce48061c2fc07c/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedScene.java#L185

Automated test added

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

PR Comment: https://git.openjdk.org/jfx/pull/1493#issuecomment-2199627928
PR Comment: https://git.openjdk.org/jfx/pull/1493#issuecomment-2199628476

Reply via email to