File tree Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -507,13 +507,33 @@ int Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
507
507
return 0 ;
508
508
}}
509
509
510
+ static void DispatchedDeleteContext (SDL_GLContext context)
511
+ {
512
+ @autoreleasepool {
513
+ SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)context;
514
+ [nscontext cleanup ];
515
+ CFRelease (context);
516
+ }
517
+ }
518
+
510
519
void Cocoa_GL_DeleteContext (_THIS, SDL_GLContext context)
511
- { @autoreleasepool
512
520
{
513
- SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)context;
514
- [nscontext cleanup ];
515
- CFRelease (context);
516
- }}
521
+ if ([NSThread isMainThread ]) {
522
+ DispatchedDeleteContext (context);
523
+ } else {
524
+ if (SDL_opengl_async_dispatch) {
525
+ dispatch_async (dispatch_get_main_queue (), ^{
526
+ DispatchedDeleteContext (context);
527
+ });
528
+ } else {
529
+ dispatch_sync (dispatch_get_main_queue (), ^{
530
+ DispatchedDeleteContext (context);
531
+ });
532
+ }
533
+ }
534
+
535
+ return true ;
536
+ }
517
537
518
538
/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */
519
539
#ifdef __clang__
You can’t perform that action at this time.
0 commit comments