Clear current GLX context before destroying the current context #867
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description
What type of PR is this? (Check one of the boxes below)
What does this pull request do?
On Linux systems using GLX, it clears the current GLX context before destroying the current context, which fixes a crash-on-startup on my system (Arch Linux, Qt 5.15.8, using an NVIDIA GPU with vendor drivers).
Have you tested your changes (if applicable)? If so, how?
I only tested it as far as that Natron doesn't crash right away anymore. Since I don't know how to use Natron yet, not having gotten to the point where I can try it before having fixed this, I haven't really performed more testing. Since I found others being affected by the same bug (#863) I wanted to share my potential fix rather sooner than later.
Futher details of this pull request
Without this, on my system, Qt somehow ends up using a GLX context that Natron already destroyed, causing a GLXBadContext crash on startup. That much I verified using GDB. I have no idea how Qt ends up using that context at all and how it ends up using it at that point. I assume it just uses the current context and somehow ends up getting a destroyed context when querying the current context, but that's just a guess based on this fix working for me.
I have no clue who of Natron, Qt or NVIDIA's GLX implementation are at really at fault, nor have I tested this beyond verifying that Natron doesn't crash on startup anymore.