Browse Source

cocoa: Set the internal window data before calling methods that may result in referencing the internal data

(cherry picked from commit 512d97eabaec3f16ffc59f486d03711861618d46)
Frank Praznik 5 months ago
parent
commit
a530df20b2
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/video/cocoa/SDL_cocoawindow.m

+ 1 - 1
src/video/cocoa/SDL_cocoawindow.m

@@ -2126,6 +2126,7 @@ static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow
         if (!data) {
             return SDL_OutOfMemory();
         }
+        window->internal = (SDL_WindowData *)CFBridgingRetain(data);
         data.window = window;
         data.nswindow = nswindow;
         data.videodata = videodata;
@@ -2246,7 +2247,6 @@ static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow
         SDL_SetNumberProperty(props, SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER, SDL_METALVIEW_TAG);
 
         // All done!
-        window->internal = (SDL_WindowData *)CFBridgingRetain(data);
         return true;
     }
 }