summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-11-25 10:20:01 +0100
committerGitHub <noreply@github.com>2020-11-25 10:20:01 +0100
commit9aeada734d4e1793ce2e7c57678e83501f292afc (patch)
treebb397c31da6051080ac2bce9724004f273ff0633
parentMerge pull request #4905 from german77/AnalogFromButton (diff)
parentcore: cpu_manager: Fix shutdown crash when closing before emulation starts. (diff)
downloadyuzu-9aeada734d4e1793ce2e7c57678e83501f292afc.tar
yuzu-9aeada734d4e1793ce2e7c57678e83501f292afc.tar.gz
yuzu-9aeada734d4e1793ce2e7c57678e83501f292afc.tar.bz2
yuzu-9aeada734d4e1793ce2e7c57678e83501f292afc.tar.lz
yuzu-9aeada734d4e1793ce2e7c57678e83501f292afc.tar.xz
yuzu-9aeada734d4e1793ce2e7c57678e83501f292afc.tar.zst
yuzu-9aeada734d4e1793ce2e7c57678e83501f292afc.zip
-rw-r--r--src/core/cpu_manager.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp
index 983210197..100e90d82 100644
--- a/src/core/cpu_manager.cpp
+++ b/src/core/cpu_manager.cpp
@@ -4,6 +4,7 @@
#include "common/fiber.h"
#include "common/microprofile.h"
+#include "common/scope_exit.h"
#include "common/thread.h"
#include "core/arm/exclusive_monitor.h"
#include "core/core.h"
@@ -343,6 +344,16 @@ void CpuManager::RunThread(std::size_t core) {
data.initialized = true;
const bool sc_sync = !is_async_gpu && !is_multicore;
bool sc_sync_first_use = sc_sync;
+
+ // Cleanup
+ SCOPE_EXIT({
+ data.host_context->Exit();
+ data.enter_barrier.reset();
+ data.exit_barrier.reset();
+ data.initialized = false;
+ MicroProfileOnThreadExit();
+ });
+
/// Running
while (running_mode) {
data.is_running = false;
@@ -351,6 +362,12 @@ void CpuManager::RunThread(std::size_t core) {
system.GPU().ObtainContext();
sc_sync_first_use = false;
}
+
+ // Abort if emulation was killed before the session really starts
+ if (!system.IsPoweredOn()) {
+ return;
+ }
+
auto& scheduler = system.Kernel().CurrentScheduler();
Kernel::Thread* current_thread = scheduler.GetCurrentThread();
data.is_running = true;
@@ -360,13 +377,6 @@ void CpuManager::RunThread(std::size_t core) {
data.exit_barrier->Wait();
data.is_paused = false;
}
- /// Time to cleanup
- data.host_context->Exit();
- data.enter_barrier.reset();
- data.exit_barrier.reset();
- data.initialized = false;
-
- MicroProfileOnThreadExit();
}
} // namespace Core