From e711494a070f395e0a12bd22bf8c81d7b3a3d9d8 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Thu, 25 Dec 2025 22:14:04 -0500 Subject: [PATCH] Reapply "dont call I_Quit from withing quit_handler, let it signal main loop to quit" This reverts commit 8156c6e2104ab6e7aec3b0c0d45d96408604e59d. --- src/d_main.cpp | 3 +++ src/i_system.h | 2 ++ src/sdl/i_system.cpp | 12 ++++++++++-- src/sdl/i_video.cpp | 3 ++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index e13859bfe..d6f53d9e4 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -991,6 +991,9 @@ void D_SRB2Loop(void) for (;;) { + if (I_Interrupted()) + I_Quit(); + precise_t enterprecise = I_GetPreciseTime(); memset(&g_dc, 0, sizeof(g_dc)); diff --git a/src/i_system.h b/src/i_system.h index bf6e359a9..7cc9c0180 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -288,6 +288,8 @@ INT32 I_StartupSystem(void); */ void I_ShutdownSystem(void); +boolean I_Interrupted(void); + /** \brief The I_GetDiskFreeSpace function \param freespace a INT64 pointer to hold the free space amount diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index b558f2a47..86796e3c1 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -525,11 +525,19 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) } #endif -FUNCNORETURN static ATTRNORETURN void quit_handler(int num) +static volatile sig_atomic_t interrupted = 0; + +boolean I_Interrupted(void) +{ + return interrupted; +} + +static void quit_handler(int num) { signal(num, SIG_DFL); //default signal action raise(num); - I_Quit(); + //I_Quit(); + interrupted = true; } #ifdef HAVE_TERMIOS diff --git a/src/sdl/i_video.cpp b/src/sdl/i_video.cpp index 210f9588e..3b7caafa4 100644 --- a/src/sdl/i_video.cpp +++ b/src/sdl/i_video.cpp @@ -1839,7 +1839,8 @@ void I_ShutdownGraphics(void) SDL_GL_DeleteContext(sdlglcontext); } #endif - SDL_QuitSubSystem(SDL_INIT_VIDEO); + if (SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO) + SDL_QuitSubSystem(SDL_INIT_VIDEO); framebuffer = SDL_FALSE; }