mirror of
https://github.com/yuzu-emu/yuzu-mainline.git
synced 2024-12-12 22:34:33 +01:00
emu_window: Create a way to Cancel the exit of a Scoped
If a GraphicsContext is destroyed before its Scoped is destroyed, this causes a crash as the Scoped tries to call a method in the destroyed context on exit. Add a way to Cancel the call when we know that calling the GraphicsContext will not work.
This commit is contained in:
parent
381f1dd2c9
commit
1f24a4e520
@ -42,11 +42,20 @@ public:
|
||||
context.MakeCurrent();
|
||||
}
|
||||
~Scoped() {
|
||||
context.DoneCurrent();
|
||||
if (active) {
|
||||
context.DoneCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
/// In the event that context was destroyed before the Scoped is destroyed, this provides a
|
||||
/// mechanism to prevent calling a destroyed object's method during the deconstructor
|
||||
void Cancel() {
|
||||
active = false;
|
||||
}
|
||||
|
||||
private:
|
||||
GraphicsContext& context;
|
||||
bool active{true};
|
||||
};
|
||||
|
||||
/// Calls MakeCurrent on the context and calls DoneCurrent when the scope for the returned value
|
||||
|
Loading…
Reference in New Issue
Block a user