Fixed bug 3529 - SDL_EGL_UnloadLibrary is not called at all on SDL_Quit
authorSam Lantinga <slouken@libsdl.org>
Sun, 01 Jan 2017 19:10:36 -0800
changeset 10741a32fd6b7412b
parent 10740 bb53965b659d
child 10742 3034ea08d805
Fixed bug 3529 - SDL_EGL_UnloadLibrary is not called at all on SDL_Quit

kaisyu

In case of OpenGLES, the sequences of loading and unloading driver library should be like that:

SDL_Init
...
SDL_GL_LoadLibrary
SDL_EGL_LoadLibrary
...
SDL_Quit
...
SDL_GL_UnloadLibrary
SDL_EGL_UnloadLibrary
...


However, according to my test results, the varible '_this->gl_config.driver_loaded' does not allow 'SDL_GL_UnloadLibrary' to call 'SDL_EGL_UnloadLibrary'.
src/video/SDL_egl.c
src/video/directfb/SDL_DirectFB_opengl.c
src/video/emscripten/SDL_emscriptenopengles.c
src/video/psp/SDL_pspgl.c
     1.1 --- a/src/video/SDL_egl.c	Thu Dec 29 11:49:18 2016 -0500
     1.2 +++ b/src/video/SDL_egl.c	Sun Jan 01 19:10:36 2017 -0800
     1.3 @@ -313,8 +313,6 @@
     1.4      }
     1.5  #endif
     1.6  
     1.7 -    _this->gl_config.driver_loaded = 1;
     1.8 -
     1.9      if (path) {
    1.10          SDL_strlcpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path) - 1);
    1.11      } else {
     2.1 --- a/src/video/directfb/SDL_DirectFB_opengl.c	Thu Dec 29 11:49:18 2016 -0500
     2.2 +++ b/src/video/directfb/SDL_DirectFB_opengl.c	Sun Jan 01 19:10:36 2017 -0800
     2.3 @@ -133,7 +133,6 @@
     2.4      SDL_DFB_DEBUG("Loaded library: %s\n", path);
     2.5  
     2.6      _this->gl_config.dll_handle = handle;
     2.7 -    _this->gl_config.driver_loaded = 1;
     2.8      if (path) {
     2.9          SDL_strlcpy(_this->gl_config.driver_path, path,
    2.10                      SDL_arraysize(_this->gl_config.driver_path));
    2.11 @@ -151,16 +150,10 @@
    2.12  DirectFB_GL_UnloadLibrary(_THIS)
    2.13  {
    2.14   #if 0
    2.15 -    int ret;
    2.16 -
    2.17 -    if (_this->gl_config.driver_loaded) {
    2.18 -
    2.19 -        ret = GL_UnloadObject(_this->gl_config.dll_handle);
    2.20 -        if (ret)
    2.21 -            SDL_DFB_ERR("Error #%d trying to unload library.\n", ret);
    2.22 -        _this->gl_config.dll_handle = NULL;
    2.23 -        _this->gl_config.driver_loaded = 0;
    2.24 -    }
    2.25 +    int ret = GL_UnloadObject(_this->gl_config.dll_handle);
    2.26 +    if (ret)
    2.27 +        SDL_DFB_ERR("Error #%d trying to unload library.\n", ret);
    2.28 +    _this->gl_config.dll_handle = NULL;
    2.29  #endif
    2.30      /* Free OpenGL memory */
    2.31      SDL_free(_this->gl_data);
     3.1 --- a/src/video/emscripten/SDL_emscriptenopengles.c	Thu Dec 29 11:49:18 2016 -0500
     3.2 +++ b/src/video/emscripten/SDL_emscriptenopengles.c	Sun Jan 01 19:10:36 2017 -0800
     3.3 @@ -70,8 +70,6 @@
     3.4          return SDL_SetError("Could not initialize EGL");
     3.5      }
     3.6  
     3.7 -    _this->gl_config.driver_loaded = 1;
     3.8 -
     3.9      if (path) {
    3.10          SDL_strlcpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path) - 1);
    3.11      } else {
     4.1 --- a/src/video/psp/SDL_pspgl.c	Thu Dec 29 11:49:18 2016 -0500
     4.2 +++ b/src/video/psp/SDL_pspgl.c	Sun Jan 01 19:10:36 2017 -0800
     4.3 @@ -47,10 +47,6 @@
     4.4  int
     4.5  PSP_GL_LoadLibrary(_THIS, const char *path)
     4.6  {
     4.7 -  if (!_this->gl_config.driver_loaded) {
     4.8 -        _this->gl_config.driver_loaded = 1;
     4.9 -  }
    4.10 -
    4.11    return 0;
    4.12  }
    4.13