Skip to content

Commit

Permalink
Merge pull request #11917 from TellowKrinkle/OGLCrash
Browse files Browse the repository at this point in the history
Common:AGL: Support making temporary contexts from the main thread
  • Loading branch information
OatmealDome authored Jun 10, 2023
2 parents 7752e24 + 28ed1f8 commit 35bb663
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Source/Core/Common/GL/GLInterface/AGL.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ static bool AttachContextToView(NSOpenGLContext* context, NSView* view, u32* wid

(void)UpdateCachedDimensions(view, width, height);

[window makeFirstResponder:view];
[context setView:view];
[window makeKeyAndOrderFront:nil];

return true;
}
Expand Down Expand Up @@ -101,9 +99,16 @@ static bool AttachContextToView(NSOpenGLContext* context, NSView* view, u32* wid
m_opengl_mode = Mode::OpenGL;

__block bool success;
dispatch_sync(dispatch_get_main_queue(), ^{
if ([NSThread isMainThread])
{
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)
{
Expand Down

0 comments on commit 35bb663

Please sign in to comment.