cocoa: Change the new sync_dispatch hint to async_dispatch.

This is so the default is safer.
This commit is contained in:
Ryan C. Gordon 2022-08-10 10:48:23 -04:00
parent c6c0a8394e
commit 3119d58ff5
No known key found for this signature in database
GPG key ID: FA148B892AB48044
2 changed files with 18 additions and 12 deletions

View file

@ -44,12 +44,12 @@
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
static SDL_bool SDL_opengl_sync_dispatch = SDL_FALSE;
static SDL_bool SDL_opengl_async_dispatch = SDL_FALSE;
static void SDLCALL
SDL_OpenGLSyncDispatchChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
SDL_OpenGLAsyncDispatchChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{
SDL_opengl_sync_dispatch = SDL_GetStringBoolean(hint, SDL_FALSE);
SDL_opengl_async_dispatch = SDL_GetStringBoolean(hint, SDL_FALSE);
}
@implementation SDLOpenGLContext : NSOpenGLContext
@ -63,7 +63,7 @@ SDL_OpenGLSyncDispatchChanged(void *userdata, const char *name, const char *oldV
self->window = NULL;
}
SDL_AddHintCallback(SDL_HINT_MAC_OPENGL_SYNC_DISPATCH, SDL_OpenGLSyncDispatchChanged, NULL);
SDL_AddHintCallback(SDL_HINT_MAC_OPENGL_ASYNC_DISPATCH, SDL_OpenGLAsyncDispatchChanged, NULL);
return self;
}
@ -147,17 +147,17 @@ SDL_OpenGLSyncDispatchChanged(void *userdata, const char *name, const char *oldV
if ([NSThread isMainThread]) {
[super update];
} else {
if (SDL_opengl_sync_dispatch) {
dispatch_sync(dispatch_get_main_queue(), ^{ [super update]; });
} else {
if (SDL_opengl_async_dispatch) {
dispatch_async(dispatch_get_main_queue(), ^{ [super update]; });
} else {
dispatch_sync(dispatch_get_main_queue(), ^{ [super update]; });
}
}
}
- (void)dealloc
{
SDL_DelHintCallback(SDL_HINT_MAC_OPENGL_SYNC_DISPATCH, SDL_OpenGLSyncDispatchChanged, NULL);
SDL_DelHintCallback(SDL_HINT_MAC_OPENGL_ASYNC_DISPATCH, SDL_OpenGLAsyncDispatchChanged, NULL);
}
@end