From 3f4ca6bf50a2448966e4f88b11584d61250b6e43 Mon Sep 17 00:00:00 2001 From: fau Date: Wed, 1 May 2024 13:51:54 +0200 Subject: [PATCH] Fix opengl context leak on vid_restart (causing thread, memory and other resource leaks) SDL opengl context must be destroyed before destroying its window and also before SDL_QuitSubSystem(SDL_INIT_VIDEO) to prevent leaks --- shared/sdl/sdl_window.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/shared/sdl/sdl_window.cpp b/shared/sdl/sdl_window.cpp index 5fa0f8b623..8ff66a8e4b 100644 --- a/shared/sdl/sdl_window.cpp +++ b/shared/sdl/sdl_window.cpp @@ -810,8 +810,17 @@ void WIN_Shutdown( void ) IN_Shutdown(); + if ( opengl_context ) { + SDL_GL_DeleteContext( opengl_context ); + opengl_context = NULL; + } + + if ( screen ) { + SDL_DestroyWindow( screen ); + screen = NULL; + } + SDL_QuitSubSystem( SDL_INIT_VIDEO ); - screen = NULL; } void GLimp_EnableLogging( qboolean enable )