mirror of
https://github.com/yuzu-mirror/yuzu
synced 2024-11-24 11:13:02 +00:00
Merge pull request #8605 from devsnek/graceful-shutdown
let games gracefully exit
This commit is contained in:
commit
6bc1a477bf
3 changed files with 14 additions and 7 deletions
|
@ -79,6 +79,11 @@ void EmuThread::run() {
|
|||
|
||||
system.GetCpuManager().OnGpuReady();
|
||||
|
||||
system.RegisterExitCallback([this]() {
|
||||
stop_source.request_stop();
|
||||
SetRunning(false);
|
||||
});
|
||||
|
||||
// Holds whether the cpu was running during the last iteration,
|
||||
// so that the DebugModeLeft signal can be emitted before the
|
||||
// next execution step
|
||||
|
|
|
@ -84,9 +84,10 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Requests for the emulation thread to stop running
|
||||
* Requests for the emulation thread to immediately stop running
|
||||
*/
|
||||
void RequestStop() {
|
||||
void ForceStop() {
|
||||
LOG_WARNING(Frontend, "Force stopping EmuThread");
|
||||
stop_source.request_stop();
|
||||
SetRunning(false);
|
||||
}
|
||||
|
|
|
@ -1710,9 +1710,6 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
|
|||
system->RegisterExecuteProgramCallback(
|
||||
[this](std::size_t program_index_) { render_window->ExecuteProgram(program_index_); });
|
||||
|
||||
// Register an Exit callback such that Core can exit the currently running application.
|
||||
system->RegisterExitCallback([this]() { render_window->Exit(); });
|
||||
|
||||
connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
|
||||
connect(render_window, &GRenderWindow::MouseActivity, this, &GMainWindow::OnMouseActivity);
|
||||
// BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views
|
||||
|
@ -1799,12 +1796,16 @@ void GMainWindow::ShutdownGame() {
|
|||
system->SetShuttingDown(true);
|
||||
system->DetachDebugger();
|
||||
discord_rpc->Pause();
|
||||
emu_thread->RequestStop();
|
||||
|
||||
RequestGameExit();
|
||||
|
||||
emit EmulationStopping();
|
||||
|
||||
// Wait for emulation thread to complete and delete it
|
||||
emu_thread->wait();
|
||||
if (!emu_thread->wait(5000)) {
|
||||
emu_thread->ForceStop();
|
||||
emu_thread->wait();
|
||||
}
|
||||
emu_thread = nullptr;
|
||||
|
||||
emulation_running = false;
|
||||
|
|
Loading…
Reference in a new issue