From 5cd0e91ea5ccbc11cd79a94fe44cbc86f26a357e Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 14 Jun 2004 17:13:46 +0000 Subject: [PATCH] EmergencyShutdownSDL, moved out of ArchHooks --- stepmania/src/SDL_utils.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/stepmania/src/SDL_utils.cpp b/stepmania/src/SDL_utils.cpp index f89ef1957d..a0de41cd4a 100644 --- a/stepmania/src/SDL_utils.cpp +++ b/stepmania/src/SDL_utils.cpp @@ -9,6 +9,7 @@ #include "RageUtil.h" #include "RageSurface.h" #include "RageSurfaceUtils.h" +#include "RageThreads.h" #include "StepMania.h" #include @@ -335,6 +336,17 @@ void SDL_UpdateHWnd() #endif } +#if defined(UNIX) +#include "archutils/Unix/EmergencyShutdown.h" +void EmergencyShutdownSDL() +{ + /* Only do this if the main thread crashes; trying to shut down from + * another thread causes crashes (eg. GL may be using TLS). */ + if( !strcmp(RageThread::GetCurThreadName(), "Main thread") && SDL_WasInit(SDL_INIT_VIDEO) ) + SDL_QuitSubSystem(SDL_INIT_VIDEO); +} +#endif + void SetupSDL() { static bool bDone = false; @@ -347,6 +359,11 @@ void SetupSDL() /* Clean up on exit. */ atexit( SDL_Quit ); + +#if defined(UNIX) + /* Attempt to shut down the window on crash. */ + RegisterEmergencyShutdownCallback( EmergencyShutdownSDL ); +#endif } /*