diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 26dde67da..9aaf6ba98 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1876,6 +1876,13 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags) window->surface_valid = SDL_FALSE; } + if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */ + if (_this->DestroyWindowFramebuffer) { + _this->DestroyWindowFramebuffer(_this, window); + } + _this->checked_texture_framebuffer = SDL_FALSE; + } + if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) { if (flags & SDL_WINDOW_OPENGL) { need_gl_load = SDL_TRUE; @@ -1906,12 +1913,6 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags) SDL_Vulkan_UnloadLibrary(); } - if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */ - if (_this->DestroyWindowFramebuffer) { - _this->DestroyWindowFramebuffer(_this, window); - } - } - if (_this->DestroyWindow && !(flags & SDL_WINDOW_FOREIGN)) { _this->DestroyWindow(_this, window); } @@ -3084,30 +3085,32 @@ void SDL_DestroyWindow(SDL_Window *window) SDL_SetMouseFocus(NULL); } - /* make no context current if this is the current context window. */ - if (window->flags & SDL_WINDOW_OPENGL) { - if (_this->current_glwin == window) { - SDL_GL_MakeCurrent(window, NULL); - } - } - if (window->surface) { window->surface->flags &= ~SDL_DONTFREE; SDL_FreeSurface(window->surface); window->surface = NULL; window->surface_valid = SDL_FALSE; } + + if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */ + if (_this->DestroyWindowFramebuffer) { + _this->DestroyWindowFramebuffer(_this, window); + } + } + + /* make no context current if this is the current context window. */ + if (window->flags & SDL_WINDOW_OPENGL) { + if (_this->current_glwin == window) { + SDL_GL_MakeCurrent(window, NULL); + } + } if (window->flags & SDL_WINDOW_OPENGL) { SDL_GL_UnloadLibrary(); } if (window->flags & SDL_WINDOW_VULKAN) { SDL_Vulkan_UnloadLibrary(); } - if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */ - if (_this->DestroyWindowFramebuffer) { - _this->DestroyWindowFramebuffer(_this, window); - } - } + if (_this->DestroyWindow) { _this->DestroyWindow(_this, window); }