Quitting Crashes Windows OS's GUI

Godot Version

4.5.1.stable

Question

My entire PC’s GUI crashed when trying to use:
get_tree().root.propagate_notification(NOTIFICATION_WM_CLOSE_REQUEST)

I found this solved ticket with the exact same issue. However, I still experienced the crash after applying the solution.

So I wanted to open this for others who might stumble upon this same problem since I can’t reply to the ticket about this.

The solution that worked for me was to instead do:
get_tree().root.propagate_notification.call_deferred(NOTIFICATION_WM_CLOSE_REQUEST)

This is likely because the button pressed signal was used to call propagate_notification and somewhere/how the system is waiting for that signal’s callback to finish before actually closing which creates an impossible state. This is just a guess however and one that I wouldn’t expect to completely crash Window’s UI. It crashed both monitors & the game was not export nor fullscreen.

In any case, like the meme, use call_deferred :slight_smile:

TIL you have to reply to mark as solved :sweat_smile:

Using call_deferred when you’re inside of a callback and want to call: propagate_notification is the solution.