mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-03-24 01:25:04 +00:00
macOS: Fix reference counts of internal window data.
Fixes crashes when destroying or recreating a window (#5664).
This commit is contained in:
parent
a48004952d
commit
e9c7b5191c
|
@ -40,7 +40,10 @@ typedef enum
|
||||||
} PendingWindowOperation;
|
} PendingWindowOperation;
|
||||||
|
|
||||||
@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
|
@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
|
||||||
SDL_WindowData *_data;
|
/* SDL_WindowData owns this Listener and has a strong reference to it.
|
||||||
|
* To avoid reference cycles, we could have either a weak or an
|
||||||
|
* unretained ref to the WindowData. */
|
||||||
|
__weak SDL_WindowData *_data;
|
||||||
BOOL observingVisible;
|
BOOL observingVisible;
|
||||||
BOOL wasCtrlLeft;
|
BOOL wasCtrlLeft;
|
||||||
BOOL wasVisible;
|
BOOL wasVisible;
|
||||||
|
|
|
@ -1653,6 +1653,12 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, NSView *nsview,
|
||||||
SDL_SetKeyboardFocus(data.window);
|
SDL_SetKeyboardFocus(data.window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* SDL_WindowData will be holding a strong reference to the NSWindow, and
|
||||||
|
* it will also call [NSWindow close] in DestroyWindow before releasing the
|
||||||
|
* NSWindow, so the extra release provided by releasedWhenClosed isn't
|
||||||
|
* necessary. */
|
||||||
|
nswindow.releasedWhenClosed = NO;
|
||||||
|
|
||||||
/* Prevents the window's "window device" from being destroyed when it is
|
/* Prevents the window's "window device" from being destroyed when it is
|
||||||
* hidden. See http://www.mikeash.com/pyblog/nsopenglcontext-and-one-shot.html
|
* hidden. See http://www.mikeash.com/pyblog/nsopenglcontext-and-one-shot.html
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue