godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.01k stars 21.17k forks source link

ExitTree no longer called with NotificationWMCloseRequest #73177

Open HubbleCommand opened 1 year ago

HubbleCommand commented 1 year ago

Godot version

4.0.rc1.mono

System information

Windows 11 Vulkan

Issue description

Back in Godot 3, ExitTree would be called on OS application close requests, not just when queue_free()'ing the node.

However, this is no longer the case. I don't know if this was intended for newer versions of Godot.

Instead of using ExitTree it's possible to listen for the NotificationWMCloseRequest notification, so it's not that big of an issue.

Steps to reproduce

Override _ExitTree(). Start the game and close it, _ExitTree() will not be called.

Minimal reproduction project

Test.zip

Sauermann commented 1 year ago

I am not sure, if this is the same issue, but you might find additional info in #67379

HubbleCommand commented 1 year ago

Here is another example, 4.0.rc1, no mono, same result: Test.zip

HubbleCommand commented 4 months ago

I'm thinking of closing this as I am guessing that this is the intended behaviour in Godot 4.x (is in 4.2 & 4.3b1), although it seems strange.

67379 isn't related. I gave NOTIFICATION_WM_CLOSE_REQUEST as an example, but it's also possible to listen for the window closing by connecting to the close_requested signal.

I guess a better question is what happens when the OS goes to close Godot. My assumption is that Godot would go to close the entire scene tree, meaning it would remove all nodes from the bottom up, with _exit_tree and tree_exiting getting called on all of them. This was the behaviour in Godot 3.x. I assume this is no longer the expected behaviour, but I haven't seen it documented anywhere.

Could this be related to the new multi-window stuff?