summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar lat9nq2022-03-07 03:37:54 -0500
committerGravatar lat9nq2022-03-07 18:21:56 -0500
commitb5e60ae1b0568d6c9e47134dd2bda70906a2dad9 (patch)
tree93c23176ccbc92e7340262a7279edbe2f3888d1c
parentemu_window: Create a way to Cancel the exit of a Scoped (diff)
downloadyuzu-b5e60ae1b0568d6c9e47134dd2bda70906a2dad9.tar.gz
yuzu-b5e60ae1b0568d6c9e47134dd2bda70906a2dad9.tar.xz
yuzu-b5e60ae1b0568d6c9e47134dd2bda70906a2dad9.zip
video_core: Cancel Scoped's exit call on GPU failure
When CreateRenderer fails, the GraphicsContext that was std::move'd into it is destroyed before the Scoped that was created to manage its currency. In that case, the GraphicsContext::Scoped will still call its destructor at the ending of the function. And because the context is destroyed, the Scoped will cause a crash as it attempts to call a destroyed object's DoneCurrent function. Since we know when the call would be invalid, call the Scoped's Cancel method. This prevents it from calling a method on a destroyed object.
Diffstat (limited to '')
-rw-r--r--src/video_core/video_core.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp
index 329bf4def..2f2594585 100644
--- a/src/video_core/video_core.cpp
+++ b/src/video_core/video_core.cpp
@@ -50,6 +50,7 @@ std::unique_ptr<Tegra::GPU> CreateGPU(Core::Frontend::EmuWindow& emu_window, Cor
50 gpu->BindRenderer(std::move(renderer)); 50 gpu->BindRenderer(std::move(renderer));
51 return gpu; 51 return gpu;
52 } catch (const std::runtime_error& exception) { 52 } catch (const std::runtime_error& exception) {
53 scope.Cancel();
53 LOG_ERROR(HW_GPU, "Failed to initialize GPU: {}", exception.what()); 54 LOG_ERROR(HW_GPU, "Failed to initialize GPU: {}", exception.what());
54 return nullptr; 55 return nullptr;
55 } 56 }