On Mon, 9 Nov 2026 18:05:52 GMT, Marius Hanl <[email protected]> wrote:

>> This PR fixes some rare NPEs I saw some users encounter when a window was 
>> hidden. The tests should cover all those potential issues and should fail 
>> without this PR and succeed with this PR.
>> 
>> I originally only wanted to fix the 1. NPE because that actually happened to 
>> some users, but during that I realized that the 2. NPE can also be provoked 
>> if you write a listener that just hides the window on some window events.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/GlassWindowEventHandler.java
>  line 69:
> 
>> 67:             case WindowEvent.MAXIMIZE:
>> 68:                 listener.changedIconified(false);
>> 69:                 listener.changedMaximized(true);
> 
> If I understand this correctly, the following sequence will happen: 
> 1. iconfied state
> 2. listener will be nulled because we `hide()` the stage
> 3. we still change / deliver the maxiimized state to the stage that otherwise 
> has no listener anymore
> 
> I don't think this is a problem. But I still want to bring this up -- does 
> this make sense / no harm in doing that?
> Otherwise we need to null check every second `changeXYZ` call.

I haven't seen issues caused by that. The listener impl still keeps track of 
the changed state, so I would say it is more correct to still call the 
listener. It makes a difference if you then reshow the stage again. If the 2. 
listener call would not be done, the state would not be up to date

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2364#discussion_r4516267739

Reply via email to