Merge pull request #11917 from TellowKrinkle/OGLCrash

Common:AGL: Support making temporary contexts from the main thread
This commit is contained in:
OatmealDome 2023-06-10 23:22:16 +02:00 committed by GitHub
commit 35bb663c2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,9 +38,7 @@ static bool AttachContextToView(NSOpenGLContext* context, NSView* view, u32* wid
(void)UpdateCachedDimensions(view, width, height); (void)UpdateCachedDimensions(view, width, height);
[window makeFirstResponder:view];
[context setView:view]; [context setView:view];
[window makeKeyAndOrderFront:nil];
return true; return true;
} }
@ -101,9 +99,16 @@ bool GLContextAGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
m_opengl_mode = Mode::OpenGL; m_opengl_mode = Mode::OpenGL;
__block bool success; __block bool success;
dispatch_sync(dispatch_get_main_queue(), ^{ if ([NSThread isMainThread])
{
success = AttachContextToView(m_context, m_view, &m_backbuffer_width, &m_backbuffer_height); success = AttachContextToView(m_context, m_view, &m_backbuffer_width, &m_backbuffer_height);
}); }
else
{
dispatch_sync(dispatch_get_main_queue(), ^{
success = AttachContextToView(m_context, m_view, &m_backbuffer_width, &m_backbuffer_height);
});
}
if (!success) if (!success)
{ {