From 165f8a4c9d08943afc998de73c8af2b83220711a Mon Sep 17 00:00:00 2001 From: Cpasjuste Date: Tue, 19 May 2020 13:15:44 +0200 Subject: [PATCH] switch: fix exit crash when using SDL_GL_Load/UnloadLibrary (#53) --- src/video/switch/SDL_switchvideo.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/video/switch/SDL_switchvideo.c b/src/video/switch/SDL_switchvideo.c index 9590de2075992..2bfa8cc147e2e 100644 --- a/src/video/switch/SDL_switchvideo.c +++ b/src/video/switch/SDL_switchvideo.c @@ -160,8 +160,11 @@ SWITCH_VideoInit(_THIS) void SWITCH_VideoQuit(_THIS) { - if (_this->gl_config.driver_loaded) { - SDL_GL_UnloadLibrary(); + // this should not be needed if user code is right (SDL_GL_LoadLibrary/SDL_GL_UnloadLibrary calls match) + // this (user) error doesn't have the same effect on switch thought, as the driver needs to be unloaded (crash) + if(_this->gl_config.driver_loaded > 0) { + SWITCH_GLES_UnloadLibrary(_this); + _this->gl_config.driver_loaded = 0; } // exit touch