SDL: mac: Fix SDLWindow nswindow member no longer being cleaned up in Cocoa_DestroyWindow

From 42f8e94d11c51c34ae4afbd615145bbbd7fe95b7 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 23 Apr 2024 06:20:30 -0700
Subject: [PATCH] mac: Fix SDLWindow nswindow member no longer being cleaned up
 in Cocoa_DestroyWindow

- A refactor changed how SetupWindowData handled external windows where previously it was tracked
  in a field of SDL_CocoaWindowData but now it is tracked by setting SDL_WINDOW_EXTERNAL in the
  window flags. Removed the now unused field and updated the external window check in DestroyWindow.
---
 src/video/cocoa/SDL_cocoawindow.h | 1 -
 src/video/cocoa/SDL_cocoawindow.m | 3 ++-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h
index 59c7ce14d91aa..4f4d9daccec2b 100644
--- a/src/video/cocoa/SDL_cocoawindow.h
+++ b/src/video/cocoa/SDL_cocoawindow.h
@@ -132,7 +132,6 @@ typedef enum
 @property(nonatomic) NSWindow *nswindow;
 @property(nonatomic) NSView *sdlContentView;
 @property(nonatomic) NSMutableArray *nscontexts;
-@property(nonatomic) SDL_bool created;
 @property(nonatomic) BOOL in_blocking_transition;
 @property(nonatomic) BOOL was_zoomed;
 @property(nonatomic) NSInteger window_number;
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 01085419810be..13f52ddc63fa6 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -2830,7 +2830,8 @@ void Cocoa_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
             }
             [data.listener close];
             data.listener = nil;
-            if (data.created) {
+
+            if (!(window->flags & SDL_WINDOW_EXTERNAL)) {
                 /* Release the content view to avoid further updateLayer callbacks */
                 [data.nswindow setContentView:nil];
                 [data.nswindow close];