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

Fixes https://github.com/libsdl-org/SDL/issues/8011
This commit is contained in:
Sam Lantinga 2023-11-07 21:44:18 -08:00
parent 4ace02df5f
commit 624905a7f1

View file

@ -980,8 +980,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);
} }
@ -1035,8 +1039,6 @@ SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface)
renderer->info = SW_RenderDriver.info; renderer->info = SW_RenderDriver.info;
renderer->driverdata = data; renderer->driverdata = data;
SW_ActivateRenderer(renderer);
return renderer; return renderer;
} }