macOS: Fix SDL_GL_CreateContext/MakeCurrent on non-main threads causing a Main Thread Checker warning when built with Xcode 11 / the macOS 10.15 SDK.
Fixes bug #4714.
This commit is contained in:
parent
73536d93ea
commit
8fb8adfc90
3 changed files with 20 additions and 2 deletions
|
@ -95,6 +95,18 @@
|
|||
|
||||
if (newWindow) {
|
||||
SDL_WindowData *windowdata = (SDL_WindowData *)newWindow->driverdata;
|
||||
NSView *contentview = windowdata->sdlContentView;
|
||||
|
||||
/* This should never be nil since sdlContentView is only nil if the
|
||||
window was created via SDL_CreateWindowFrom, and SDL doesn't allow
|
||||
OpenGL contexts to be created in that case. However, it doesn't hurt
|
||||
to check. */
|
||||
if (contentview == nil) {
|
||||
/* Prefer to access the cached content view above instead of this,
|
||||
since as of Xcode 11 + SDK 10.15, [window contentView] causes
|
||||
Apple's Main Thread Checker to output a warning. */
|
||||
contentview = [windowdata->nswindow contentView];
|
||||
}
|
||||
|
||||
/* Now sign up for scheduled updates for the new window. */
|
||||
NSMutableArray *contexts = windowdata->nscontexts;
|
||||
|
@ -102,8 +114,8 @@
|
|||
[contexts addObject:self];
|
||||
}
|
||||
|
||||
if ([self view] != [windowdata->nswindow contentView]) {
|
||||
[self setView:[windowdata->nswindow contentView]];
|
||||
if ([self view] != contentview) {
|
||||
[self setView:contentview];
|
||||
if (self == [NSOpenGLContext currentContext]) {
|
||||
[self update];
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue