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