diff options
| author | 2015-04-27 23:13:57 -0400 | |
|---|---|---|
| committer | 2015-05-01 18:27:06 -0400 | |
| commit | 3dd268878570c2c48e2be4018ff4d0ea851ece60 (patch) | |
| tree | b00f5eb003d5f3f34d5a34190a3e645fe854e0d4 /src | |
| parent | CoreTiming: Initialize static variables at bootup. (diff) | |
| download | yuzu-3dd268878570c2c48e2be4018ff4d0ea851ece60.tar.gz yuzu-3dd268878570c2c48e2be4018ff4d0ea851ece60.tar.xz yuzu-3dd268878570c2c48e2be4018ff4d0ea851ece60.zip | |
Qt: Fix loading a new game without stopping emulation.
Diffstat (limited to 'src')
| -rw-r--r-- | src/citra_qt/main.cpp | 39 | ||||
| -rw-r--r-- | src/citra_qt/main.h | 1 |
2 files changed, 25 insertions, 15 deletions
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index fe1dac622..5441c17f1 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp | |||
| @@ -199,6 +199,10 @@ void GMainWindow::OnDisplayTitleBars(bool show) | |||
| 199 | void GMainWindow::BootGame(std::string filename) { | 199 | void GMainWindow::BootGame(std::string filename) { |
| 200 | LOG_INFO(Frontend, "Citra starting...\n"); | 200 | LOG_INFO(Frontend, "Citra starting...\n"); |
| 201 | 201 | ||
| 202 | // Shutdown previous session if the emu thread is still active... | ||
| 203 | if (emu_thread != nullptr) | ||
| 204 | ShutdownGame(); | ||
| 205 | |||
| 202 | System::Init(render_window); | 206 | System::Init(render_window); |
| 203 | 207 | ||
| 204 | // Load a game or die... | 208 | // Load a game or die... |
| @@ -217,6 +221,25 @@ void GMainWindow::BootGame(std::string filename) { | |||
| 217 | OnStartGame(); | 221 | OnStartGame(); |
| 218 | } | 222 | } |
| 219 | 223 | ||
| 224 | void GMainWindow::ShutdownGame() { | ||
| 225 | emu_thread->SetCpuRunning(false); | ||
| 226 | |||
| 227 | emu_thread->ShutdownCpu(); | ||
| 228 | emu_thread->WaitForCpuShutdown(); | ||
| 229 | emu_thread->Stop(); | ||
| 230 | |||
| 231 | delete emu_thread; | ||
| 232 | emu_thread = nullptr; | ||
| 233 | |||
| 234 | System::Shutdown(); | ||
| 235 | |||
| 236 | ui.action_Start->setEnabled(true); | ||
| 237 | ui.action_Pause->setEnabled(false); | ||
| 238 | ui.action_Stop->setEnabled(false); | ||
| 239 | |||
| 240 | render_window->hide(); | ||
| 241 | } | ||
| 242 | |||
| 220 | void GMainWindow::OnMenuLoadFile() | 243 | void GMainWindow::OnMenuLoadFile() |
| 221 | { | 244 | { |
| 222 | QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), QString(), tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.bin *.cci *.cxi)")); | 245 | QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), QString(), tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.bin *.cci *.cxi)")); |
| @@ -249,21 +272,7 @@ void GMainWindow::OnPauseGame() | |||
| 249 | } | 272 | } |
| 250 | 273 | ||
| 251 | void GMainWindow::OnStopGame() { | 274 | void GMainWindow::OnStopGame() { |
| 252 | emu_thread->SetCpuRunning(false); | 275 | ShutdownGame(); |
| 253 | |||
| 254 | emu_thread->ShutdownCpu(); | ||
| 255 | emu_thread->WaitForCpuShutdown(); | ||
| 256 | emu_thread->Stop(); | ||
| 257 | |||
| 258 | delete emu_thread; | ||
| 259 | |||
| 260 | System::Shutdown(); | ||
| 261 | |||
| 262 | ui.action_Start->setEnabled(true); | ||
| 263 | ui.action_Pause->setEnabled(false); | ||
| 264 | ui.action_Stop->setEnabled(false); | ||
| 265 | |||
| 266 | render_window->hide(); | ||
| 267 | } | 276 | } |
| 268 | 277 | ||
| 269 | void GMainWindow::OnOpenHotkeysDialog() | 278 | void GMainWindow::OnOpenHotkeysDialog() |
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index 5b33ea962..1821ae35f 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h | |||
| @@ -41,6 +41,7 @@ public: | |||
| 41 | 41 | ||
| 42 | private: | 42 | private: |
| 43 | void BootGame(std::string filename); | 43 | void BootGame(std::string filename); |
| 44 | void ShutdownGame(); | ||
| 44 | 45 | ||
| 45 | void closeEvent(QCloseEvent* event) override; | 46 | void closeEvent(QCloseEvent* event) override; |
| 46 | 47 | ||