mirror of https://github.com/libsdl-org/SDL.git
cocoa: Make sure GL context destruction happens on the main thread.
Fixes #10900.
This commit is contained in:
parent
dcd4ddb043
commit
344546b4ea
|
|
@ -523,13 +523,31 @@ bool Cocoa_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Cocoa_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context)
|
static void DispatchedDestroyContext(SDL_GLContext context)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
SDL3OpenGLContext *nscontext = (__bridge SDL3OpenGLContext *)context;
|
SDL3OpenGLContext *nscontext = (__bridge SDL3OpenGLContext *)context;
|
||||||
[nscontext cleanup];
|
[nscontext cleanup];
|
||||||
CFRelease(context);
|
CFRelease(context);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Cocoa_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context)
|
||||||
|
{
|
||||||
|
if ([NSThread isMainThread]) {
|
||||||
|
DispatchedDestroyContext(context);
|
||||||
|
} else {
|
||||||
|
if (SDL_opengl_async_dispatch) {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
DispatchedDestroyContext(context);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||||
|
DispatchedDestroyContext(context);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue