From d2f7973c29fded2dcbe73806e754eb7ad853518d Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Sat, 21 Aug 2010 16:26:34 +0000 Subject: [PATCH] Fix system-dependent crash on exiting This was SVN commit r8013. --- source/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index fbe6ec0fb0..b62a90a602 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -200,6 +200,8 @@ static int ProgressiveLoad() } +static bool quit = false; // break out of main loop + static void Frame() { MICROLOG(L"Frame"); @@ -269,6 +271,12 @@ static void Frame() PumpEvents(); PROFILE_END("input"); + // if the user quit by closing the window, the GL context will be broken and + // may crash when we call Render() on some drivers, so leave this loop + // before rendering + if (quit) + return; + // respond to pumped resize events if (g_ResizedW || g_ResizedH) { @@ -372,8 +380,6 @@ static void MainControllerShutdown() } -static bool quit = false; // break out of main loop - // stop the main loop and trigger orderly shutdown. called from several // places: the event handler (SDL_QUIT and hotkey) and JS exitProgram. void kill_mainloop()