浏览代码

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.
Frank Praznik 2 年之前
父节点
当前提交
8f14fa1113
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      src/video/SDL_video.c

+ 5 - 0
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 */