Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt: Fix gl-gs-frame error in debug builds #16614

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Megamouse
Copy link
Contributor

This code causes exceptions in debug builds if not called from the main thread.

{
const auto context = static_cast<GLContext*>(ctx);

if (context->handle->makeCurrent(context->surface))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. This is wrong.
GLRC makeCurrent means "make this context the current one on this thread".
We don't want it attached to main thread, we want it attached to the caller. It's how you do multithreading in OGL.

}

void gl_gs_frame::delete_context(draw_context_t ctx)
{
const auto gl_ctx = static_cast<GLContext*>(ctx);

gl_ctx->handle->doneCurrent();
// Calling this on the main thread is necessery in debug builds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, cannot be done from main thread. Anything with "current" is thread-local

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants