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

Prasanta Sadhukhan psadhukhan at openjdk.org
Mon Jul 1 05:49:24 UTC 2024


On Mon, 1 Jul 2024 05:44:21 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> Can you add an automated test to cover this fix?
>> 
>> Worth noting, this won't fully solve the problem that the reporter of this bug filed. The null check will prevent the NPE, but the scene will still not be visible. To allow removing and then re-adding the `JFXPanel`, we would need to not call `Window.hide` when the `JFXPanel` is removed. We should file a follow-on Enhancement to consider doing this, but that will need more discussion. The main point that would need to be solved is to figure out when to call `Window.hide` if not when the `JFXPanel` is  removed.
>
>> To allow removing and then re-adding the `JFXPanel`, we would need to not call `Window.hide` when the `JFXPanel` is removed.
> 
> I am not sure if this is a problem as just as `JFXPanel.removeNotify` does `Window.hide` but at the same time when we add JFXPanel to frame, it calls `JFXPanel.addNotify` which does `Window.show` so tit gets hidden when JFXPanel is removed and shown when JFXPanel is added

> @prsadhuk One more question: Do you know what changed in JavaFX 21 to trigger the NPE?

It is not reproducible in jfx21 as per my testing...The problematic code to call updateSceneState was added for [JDK-8274932](https://bugs.openjdk.org/browse/JDK-8274932) so it has regressed from jfx22

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

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


More information about the openjfx-dev mailing list