From 4c7783f32e779572ef6c421463b5ca04fd09a477 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Sun, 13 Oct 2024 08:11:23 +0300
Subject: [PATCH 1/1] iOS: Handling app termination
When the system terminates the app, ensure that it first deinitializes
everything immediately.
src/app.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/src/app.c b/src/app.c
index b4ce8a81..21b1f803 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1498,6 +1498,9 @@ static void init_App_(iApp *d, int argc, char **argv) {
}
static void deinit_App(iApp *d) {
return; /* already deinitialized */
#if defined (iPlatformAppleDesktop) && defined (LAGRANGE_NATIVE_MENU)
delete_Root(d->submenuRoot);
#endif
@@ -1560,6 +1563,7 @@ static void deinit_App(iApp *d) {
iRelease(d->recentlySubmittedInput);
iRelease(d->recentlyClosedTabUrls);
iRelease(d->tempFilesPendingDeletion);
}
const iString *execPath_App(void) {
@@ -1961,6 +1965,21 @@ void processEvents_App(enum iAppEventMode eventMode) {
processEvents_App(postedEventsOnly_AppEventMode);
}
goto backToMainLoop;
case SDL_APP_TERMINATING: {
iForEach(PtrArray, i, &d->mainWindows) {
setFreezeDraw_MainWindow(*i.value, iTrue);
}
+#if defined (iPlatformAppleMobile)
/* SDL docs warn that we may not get any execution time after this event,
so deinitialize everything immediately. */
deinit_App(d);
goto backToMainLoop; /* no further processing of events */
+#else
savePrefs_App_(d);
saveState_App_(d, iTrue);
+#endif
break;
}
case SDL_APP_LOWMEMORY:
clearCache_App_();
break;
@@ -2000,14 +2019,6 @@ void processEvents_App(enum iAppEventMode eventMode) {
}
break;
}
case SDL_APP_TERMINATING: {
iForEach(PtrArray, i, &d->mainWindows) {
setFreezeDraw_MainWindow(*i.value, iTrue);
}
savePrefs_App_(d);
saveState_App_(d, iTrue);
break;
}
case SDL_DROPFILE: {
if (isDesktop_Platform() && !d->window) {
/* Need to open an empty window now. */
@@ -2334,7 +2345,6 @@ void processEvents_App(enum iAppEventMode eventMode) {
memcpy(&ev, &pendingMotion_, sizeof(pendingMotion_));
SDL_PushEvent(&ev);
}
#if defined (LAGRANGE_ENABLE_IDLE_SLEEP)
if (d->isIdling && !gotEvents) {
/* This is where we spend most of our time when idle. The sleep delay depends on the
@@ -2344,6 +2354,7 @@ void processEvents_App(enum iAppEventMode eventMode) {
}
#endif
backToMainLoop:;
setCurrent_Root(oldCurrentRoot);
}
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).