SDL: video: Destroy the associated renderer when a window is destroyed

From 8f14fa1113b8345cb09a33fa99368b673caa87a1 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Tue, 26 Mar 2024 14:43:33 -0400
Subject: [PATCH] video: Destroy the associated renderer when a window is
 destroyed

This was previous behavior that used window userdata and was lost during the move to properties.  Renderer objects need to be cleaned up when their associated windows are destroyed, or they can be leaked and backend refcounts won't be properly updated, leading to them not being properly shut down when SDL_Quit() is called.
---
 src/video/SDL_video.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 6dd44fc2d1149..1ce0528c18ec3 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -3635,6 +3635,11 @@ void SDL_DestroyWindow(SDL_Window *window)
 
     SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_DESTROYED, 0, 0);
 
+    SDL_Renderer *renderer = SDL_GetRenderer(window);
+    if (renderer) {
+        SDL_DestroyRenderer(renderer);
+    }
+
     SDL_DestroyProperties(window->props);
 
     /* If this is a child window, unlink it from its siblings */