Destroy the window surface if we've created it for the software renderer

Fixes https://github.com/libsdl-org/SDL/issues/8011
main
Sam Lantinga 2023-11-07 21:44:18 -08:00
parent 28e623c504
commit 521bbcc15e
1 changed files with 4 additions and 2 deletions

View File

@ -990,8 +990,12 @@ static void SW_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
static void SW_DestroyRenderer(SDL_Renderer *renderer) static void SW_DestroyRenderer(SDL_Renderer *renderer)
{ {
SDL_Window *window = renderer->window;
SW_RenderData *data = (SW_RenderData *)renderer->driverdata; SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
if (window) {
SDL_DestroyWindowSurface(window);
}
SDL_free(data); SDL_free(data);
SDL_free(renderer); SDL_free(renderer);
} }
@ -1140,8 +1144,6 @@ SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface)
SW_SelectBestFormats(renderer, surface->format->format); SW_SelectBestFormats(renderer, surface->format->format);
SW_ActivateRenderer(renderer);
return renderer; return renderer;
} }