From a432abf4cc275ded95def1412ac95eee42f08948 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 17 Oct 2024 16:38:07 -0700
Subject: [PATCH] Make sure that we quit if we get a terminating event
This covers the case where the application didn't handle the quit or terminating event, we still need the main loop to finish.
---
src/main/SDL_main_callbacks.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/main/SDL_main_callbacks.c b/src/main/SDL_main_callbacks.c
index 60316c0943981..0a6e6854f55d1 100644
--- a/src/main/SDL_main_callbacks.c
+++ b/src/main/SDL_main_callbacks.c
@@ -75,6 +75,11 @@ static bool SDLCALL SDL_MainCallbackEventWatcher(void *userdata, SDL_Event *even
// Make sure any currently queued events are processed then dispatch this before continuing
SDL_DispatchMainCallbackEvents();
SDL_DispatchMainCallbackEvent(event);
+
+ // Make sure that we quit if we get a terminating event
+ if (event->type == SDL_EVENT_TERMINATING) {
+ SDL_CompareAndSwapAtomicInt(&apprc, SDL_APP_CONTINUE, SDL_APP_SUCCESS);
+ }
} else {
// We'll process this event later from the main event queue
}