src/video/cocoa/SDL_cocoaopengl.m
changeset 12940 1e6980ce45c0
parent 12863 bddd4ba329cc
     1.1 --- a/src/video/cocoa/SDL_cocoaopengl.m	Fri Jul 12 21:28:43 2019 -0400
     1.2 +++ b/src/video/cocoa/SDL_cocoaopengl.m	Sat Jul 13 17:04:02 2019 -0300
     1.3 @@ -95,6 +95,18 @@
     1.4  
     1.5      if (newWindow) {
     1.6          SDL_WindowData *windowdata = (SDL_WindowData *)newWindow->driverdata;
     1.7 +        NSView *contentview = windowdata->sdlContentView;
     1.8 +
     1.9 +        /* This should never be nil since sdlContentView is only nil if the
    1.10 +           window was created via SDL_CreateWindowFrom, and SDL doesn't allow
    1.11 +           OpenGL contexts to be created in that case. However, it doesn't hurt
    1.12 +           to check. */
    1.13 +        if (contentview == nil) {
    1.14 +            /* Prefer to access the cached content view above instead of this,
    1.15 +               since as of Xcode 11 + SDK 10.15, [window contentView] causes
    1.16 +               Apple's Main Thread Checker to output a warning. */
    1.17 +            contentview = [windowdata->nswindow contentView];
    1.18 +        }
    1.19  
    1.20          /* Now sign up for scheduled updates for the new window. */
    1.21          NSMutableArray *contexts = windowdata->nscontexts;
    1.22 @@ -102,8 +114,8 @@
    1.23              [contexts addObject:self];
    1.24          }
    1.25  
    1.26 -        if ([self view] != [windowdata->nswindow contentView]) {
    1.27 -            [self setView:[windowdata->nswindow contentView]];
    1.28 +        if ([self view] != contentview) {
    1.29 +            [self setView:contentview];
    1.30              if (self == [NSOpenGLContext currentContext]) {
    1.31                  [self update];
    1.32              } else {