diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index 21ed3fd39..5ceeced80 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -65,6 +65,7 @@ void MainLoop::_bind_methods() { BIND_CONSTANT(NOTIFICATION_OS_IME_UPDATE); BIND_CONSTANT(NOTIFICATION_APP_RESUMED); BIND_CONSTANT(NOTIFICATION_APP_PAUSED); + BIND_CONSTANT(NOTIFICATION_QUITTING); ADD_SIGNAL(MethodInfo("on_request_permissions_result", PropertyInfo(Variant::STRING, "permission"), PropertyInfo(Variant::BOOL, "granted"))); }; diff --git a/core/os/main_loop.h b/core/os/main_loop.h index ac236eb16..36617ee8d 100644 --- a/core/os/main_loop.h +++ b/core/os/main_loop.h @@ -62,6 +62,7 @@ public: NOTIFICATION_OS_IME_UPDATE = 1013, NOTIFICATION_APP_RESUMED = 1014, NOTIFICATION_APP_PAUSED = 1015, + NOTIFICATION_QUITTING = 1016, }; virtual void input_event(const Ref &p_event); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 7db975d5a..96029dc60 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -879,6 +879,8 @@ void SceneTree::quit(int p_exit_code) { } _quit = true; + + notification(NOTIFICATION_QUITTING); } void SceneTree::_notification(int p_notification) { @@ -888,6 +890,7 @@ void SceneTree::_notification(int p_notification) { if (accept_quit) { _quit = true; + get_root()->propagate_notification(NOTIFICATION_QUITTING); break; } } break; @@ -897,6 +900,7 @@ void SceneTree::_notification(int p_notification) { if (quit_on_go_back) { _quit = true; + get_root()->propagate_notification(NOTIFICATION_QUITTING); break; } } break; @@ -948,7 +952,9 @@ void SceneTree::_notification(int p_notification) { case NOTIFICATION_CRASH: { get_root()->propagate_notification(p_notification); } break; - + case NOTIFICATION_QUITTING: { + get_root()->propagate_notification(p_notification); + } break; default: break; };