From 870c5bbb4ebb91fc539482fb69277db10edc2910 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Wed, 9 Mar 2022 03:48:53 +0100 Subject: [PATCH] early-access version 2535 --- README.md | 2 +- src/core/core.cpp | 4 +++- src/core/frontend/emu_window.h | 11 ++++++++++- src/core/hle/service/ldr/ldr.cpp | 2 +- src/video_core/video_core.cpp | 1 + 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a37da81ac..d36e28d0f 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2533. +This is the source code for early-access 2535. ## Legal Notice diff --git a/src/core/core.cpp b/src/core/core.cpp index b0cfee3ee..c60a784c3 100755 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -326,7 +326,9 @@ struct System::Impl { is_powered_on = false; exit_lock = false; - gpu_core->NotifyShutdown(); + if (gpu_core != nullptr) { + gpu_core->NotifyShutdown(); + } services.reset(); service_manager.reset(); diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index e413a520a..b3bffecb2 100755 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h @@ -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 diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp index 4f7b93236..099276420 100755 --- a/src/core/hle/service/ldr/ldr.cpp +++ b/src/core/hle/service/ldr/ldr.cpp @@ -312,7 +312,7 @@ public: size = Common::AlignUp(size, Kernel::PageSize); size += page_table.GetNumGuardPages() * Kernel::PageSize * 4; - auto is_region_available = [&](VAddr addr) { + const auto is_region_available = [&](VAddr addr) { const auto end_addr = addr + size; while (addr < end_addr) { if (system.Memory().IsValidVirtualAddress(addr)) { diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index 329bf4def..2f2594585 100755 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp @@ -50,6 +50,7 @@ std::unique_ptr CreateGPU(Core::Frontend::EmuWindow& emu_window, Cor gpu->BindRenderer(std::move(renderer)); return gpu; } catch (const std::runtime_error& exception) { + scope.Cancel(); LOG_ERROR(HW_GPU, "Failed to initialize GPU: {}", exception.what()); return nullptr; }