From af3e1fc58012ee1408aeefb9732cfec5faad3fc0 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 3 Jan 2018 00:45:52 +0300 Subject: [PATCH] Improve Restart function Don't erase boot args Should now work correctly with game launchers --- rpcs3/Emu/System.cpp | 10 ++++++++-- rpcs3/Emu/System.h | 3 ++- rpcs3/rpcs3qt/gs_frame.cpp | 2 +- rpcs3/rpcs3qt/main_window.cpp | 6 +++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 9d7e7a1e0a..c4cf4a504e 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -920,7 +920,7 @@ void Emulator::Resume() GetCallbacks().on_resume(); } -void Emulator::Stop() +void Emulator::Stop(bool restart) { if (m_state.exchange(system_state::stopped) == system_state::stopped) { @@ -928,7 +928,7 @@ void Emulator::Stop() return; } - const bool do_exit = !m_force_boot && g_cfg.misc.autoexit; + const bool do_exit = !restart && !m_force_boot && g_cfg.misc.autoexit; LOG_NOTICE(GENERAL, "Stopping emulator..."); @@ -992,6 +992,12 @@ void Emulator::Stop() jit_finalize(); #endif + if (restart) + { + return Load(); + } + + // Boot arg cleanup (preserved in the case restarting) argv.clear(); envp.clear(); data.clear(); diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index f5303209f0..769dedd866 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -262,7 +262,8 @@ public: void Run(); bool Pause(); void Resume(); - void Stop(); + void Stop(bool restart = false); + void Restart() { Stop(true); } bool IsRunning() const { return m_state == system_state::running; } bool IsPaused() const { return m_state == system_state::paused; } diff --git a/rpcs3/rpcs3qt/gs_frame.cpp b/rpcs3/rpcs3qt/gs_frame.cpp index f98431ad77..96277edd80 100644 --- a/rpcs3/rpcs3qt/gs_frame.cpp +++ b/rpcs3/rpcs3qt/gs_frame.cpp @@ -87,7 +87,7 @@ void gs_frame::keyPressEvent(QKeyEvent *keyEvent) if (keyEvent->modifiers() == Qt::ControlModifier && (!Emu.IsStopped())) { Emu.Stop(); return; } break; case Qt::Key_R: - if (keyEvent->modifiers() == Qt::ControlModifier && (!Emu.GetBoot().empty())) { Emu.SetForceBoot(true); Emu.Stop(); Emu.Load(); return; } + if (keyEvent->modifiers() == Qt::ControlModifier && (!Emu.GetBoot().empty())) { Emu.Restart(); return; } break; case Qt::Key_E: if (keyEvent->modifiers() == Qt::ControlModifier) diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 6c22ae9deb..f62d67bd60 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -172,7 +172,7 @@ void main_window::CreateThumbnailToolbar() RepaintThumbnailIcons(); connect(m_thumb_stop, &QWinThumbnailToolButton::clicked, [=]() { Emu.Stop(); }); - connect(m_thumb_restart, &QWinThumbnailToolButton::clicked, [=]() { Emu.SetForceBoot(true); Emu.Stop(); Emu.Load(); }); + connect(m_thumb_restart, &QWinThumbnailToolButton::clicked, [=]() { Emu.Restart(); }); connect(m_thumb_playPause, &QWinThumbnailToolButton::clicked, Pause); #endif } @@ -1093,7 +1093,7 @@ void main_window::CreateConnects() connect(ui->exitAct, &QAction::triggered, this, &QWidget::close); connect(ui->sysPauseAct, &QAction::triggered, Pause); connect(ui->sysStopAct, &QAction::triggered, [=]() { Emu.Stop(); }); - connect(ui->sysRebootAct, &QAction::triggered, [=]() { Emu.SetForceBoot(true); Emu.Stop(); Emu.Load(); }); + connect(ui->sysRebootAct, &QAction::triggered, [=]() { Emu.Restart(); }); connect(ui->sysSendOpenMenuAct, &QAction::triggered, [=] { @@ -1515,7 +1515,7 @@ void main_window::keyPressEvent(QKeyEvent *keyEvent) case Qt::Key_E: if (Emu.IsPaused()) Emu.Resume(); else if (Emu.IsReady()) Emu.Run(); return; case Qt::Key_P: if (Emu.IsRunning()) Emu.Pause(); return; case Qt::Key_S: if (!Emu.IsStopped()) Emu.Stop(); return; - case Qt::Key_R: if (!Emu.GetBoot().empty()) { Emu.SetForceBoot(true); Emu.Stop(); Emu.Run(); } return; + case Qt::Key_R: if (!Emu.GetBoot().empty()) Emu.Restart(); return; } } }