From bc8eba100254a71eb60e96bbc41940bcb4da5bcc Mon Sep 17 00:00:00 2001 From: prefect Date: Thu, 6 Oct 2005 03:29:26 +0000 Subject: [PATCH] Work around a bug in ATI's Linux OpenGL driver. This was SVN commit r2857. --- source/ps/GameSetup/GameSetup.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index fa880cd2e0..ac12fb588c 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -98,6 +98,16 @@ static int SetVideoMode(int w, int h, int bpp, bool fullscreen) if(!SDL_SetVideoMode(w, h, bpp, flags)) return -1; + // Work around a bug in the proprietary Linux ATI driver (at least versions 8.16.20 and 8.14.13). + // The driver appears to register its own atexit hook on context creation. + // If this atexit hook is called before SDL_Quit destroys the OpenGL context, + // some kind of double-free problem causes a crash and lockup in the driver. + // Calling SDL_Quit twice appears to be harmless, though, and avoids the problem + // by destroying the context *before* the driver's atexit hook is called. + // (Note that atexit hooks are guarantueed to be called in reverse order of their registration.) + atexit(SDL_Quit); + // End work around. + glViewport(0, 0, w, h); #ifndef NO_GUI