Added NOTIFICATION_QUITTING to MainLoop.

This commit is contained in:
Relintai 2025-02-08 11:24:16 +01:00
parent b264a837a8
commit c85768ae8a
3 changed files with 9 additions and 1 deletions

View File

@ -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")));
};

View File

@ -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<InputEvent> &p_event);

View File

@ -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;
};