SDL: Fixed Metal ARC leak when freeing GPU window data (thanks @imjakey!)

From 6772e3fd17472d0c50ccb7ab0c824392f3016889 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 20 Sep 2026 10:29:45 -0700
Subject: [PATCH] Fixed Metal ARC leak when freeing GPU window data (thanks
 @imjakey!)

Fixes https://github.com/libsdl-org/SDL/issues/16345
---
 src/gpu/metal/SDL_gpu_metal.m | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/gpu/metal/SDL_gpu_metal.m b/src/gpu/metal/SDL_gpu_metal.m
index fcc2aaf77f315..c8cd99fedc615 100644
--- a/src/gpu/metal/SDL_gpu_metal.m
+++ b/src/gpu/metal/SDL_gpu_metal.m
@@ -3837,6 +3837,10 @@ static void METAL_ReleaseWindow(
         }
         SDL_UnlockMutex(renderer->windowLock);
 
+        windowData->layer = nil;
+        windowData->drawable = nil;
+        windowData->texture.hanlde = nil;
+
         SDL_free(windowData);
 
         SDL_ClearProperty(SDL_GetWindowProperties(window), WINDOW_PROPERTY_DATA);