Don't unload graphics libraries until after the window has been destroyed.

This fixes creating a window after the first window has been destroyed on Android. The graphics library had been unloaded, so eglDestroySurface() wasn't called, leaving a surface attached to the window, which would prevent attaching new EGL surfaces to the window (eglCreateWindowSurface() would fail with BAD_ALLOC)
This commit is contained in:
Sam Lantinga 2023-12-12 23:17:41 -08:00
parent 69288038ed
commit b0e7b7db6f
1 changed files with 7 additions and 5 deletions

View File

@ -3621,12 +3621,18 @@ void SDL_DestroyWindow(SDL_Window *window)
} }
} }
/* make no context current if this is the current context window. */ /* Make no context current if this is the current context window */
if (window->flags & SDL_WINDOW_OPENGL) { if (window->flags & SDL_WINDOW_OPENGL) {
if (_this->current_glwin == window) { if (_this->current_glwin == window) {
SDL_GL_MakeCurrent(window, NULL); SDL_GL_MakeCurrent(window, NULL);
} }
} }
if (_this->DestroyWindow) {
_this->DestroyWindow(_this, window);
}
/* Unload the graphics libraries after the window is destroyed, which may clean up EGL surfaces */
if (window->flags & SDL_WINDOW_OPENGL) { if (window->flags & SDL_WINDOW_OPENGL) {
SDL_GL_UnloadLibrary(); SDL_GL_UnloadLibrary();
} }
@ -3634,10 +3640,6 @@ void SDL_DestroyWindow(SDL_Window *window)
SDL_Vulkan_UnloadLibrary(); SDL_Vulkan_UnloadLibrary();
} }
if (_this->DestroyWindow) {
_this->DestroyWindow(_this, window);
}
if (_this->grabbed_window == window) { if (_this->grabbed_window == window) {
_this->grabbed_window = NULL; /* ungrabbing input. */ _this->grabbed_window = NULL; /* ungrabbing input. */
} }