summaryrefslogtreecommitdiff
path: root/src/citra_qt/main.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2015-04-28 19:03:01 -0400
committerGravatar bunnei2015-05-01 18:27:07 -0400
commite4ea133717a5292339c134160da984ba186d3de8 (patch)
treef6c3e289eaee3c79375d136279509523d4b3aca8 /src/citra_qt/main.cpp
parentQt: Fix loading a new game without stopping emulation. (diff)
downloadyuzu-e4ea133717a5292339c134160da984ba186d3de8.tar.gz
yuzu-e4ea133717a5292339c134160da984ba186d3de8.tar.xz
yuzu-e4ea133717a5292339c134160da984ba186d3de8.zip
Qt: Restructured to remove unnecessary shutdown event and various cleanups.
Diffstat (limited to 'src/citra_qt/main.cpp')
-rw-r--r--src/citra_qt/main.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 5441c17f1..dd180baa4 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -199,10 +199,6 @@ void GMainWindow::OnDisplayTitleBars(bool show)
199void GMainWindow::BootGame(std::string filename) { 199void 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
206 System::Init(render_window); 202 System::Init(render_window);
207 203
208 // Load a game or die... 204 // Load a game or die...
@@ -222,29 +218,36 @@ void GMainWindow::BootGame(std::string filename) {
222} 218}
223 219
224void GMainWindow::ShutdownGame() { 220void GMainWindow::ShutdownGame() {
225 emu_thread->SetCpuRunning(false); 221 // Shutdown the emulation thread and wait for it to complete
226 222 emu_thread->SetRunning(false);
227 emu_thread->ShutdownCpu(); 223 emu_thread->Shutdown();
228 emu_thread->WaitForCpuShutdown(); 224 emu_thread->wait();
229 emu_thread->Stop();
230
231 delete emu_thread; 225 delete emu_thread;
232 emu_thread = nullptr; 226 emu_thread = nullptr;
233 227
228 // Release emu threads from any breakpoints
229 Pica::g_debug_context->ClearBreakpoints();
230
231 // Shutdown the core emulation
234 System::Shutdown(); 232 System::Shutdown();
235 233
234 // Update the GUI
236 ui.action_Start->setEnabled(true); 235 ui.action_Start->setEnabled(true);
237 ui.action_Pause->setEnabled(false); 236 ui.action_Pause->setEnabled(false);
238 ui.action_Stop->setEnabled(false); 237 ui.action_Stop->setEnabled(false);
239
240 render_window->hide(); 238 render_window->hide();
241} 239}
242 240
243void GMainWindow::OnMenuLoadFile() 241void GMainWindow::OnMenuLoadFile()
244{ 242{
245 QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), QString(), tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.bin *.cci *.cxi)")); 243 QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), QString(), tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.bin *.cci *.cxi)"));
246 if (filename.size()) 244 if (filename.size()) {
247 BootGame(filename.toLatin1().data()); 245 // Shutdown previous session if the emu thread is still active...
246 if (emu_thread != nullptr)
247 ShutdownGame();
248
249 BootGame(filename.toLatin1().data());
250 }
248} 251}
249 252
250void GMainWindow::OnMenuLoadSymbolMap() { 253void GMainWindow::OnMenuLoadSymbolMap() {
@@ -255,7 +258,7 @@ void GMainWindow::OnMenuLoadSymbolMap() {
255 258
256void GMainWindow::OnStartGame() 259void GMainWindow::OnStartGame()
257{ 260{
258 emu_thread->SetCpuRunning(true); 261 emu_thread->SetRunning(true);
259 262
260 ui.action_Start->setEnabled(false); 263 ui.action_Start->setEnabled(false);
261 ui.action_Pause->setEnabled(true); 264 ui.action_Pause->setEnabled(true);
@@ -264,7 +267,7 @@ void GMainWindow::OnStartGame()
264 267
265void GMainWindow::OnPauseGame() 268void GMainWindow::OnPauseGame()
266{ 269{
267 emu_thread->SetCpuRunning(false); 270 emu_thread->SetRunning(false);
268 271
269 ui.action_Start->setEnabled(true); 272 ui.action_Start->setEnabled(true);
270 ui.action_Pause->setEnabled(false); 273 ui.action_Pause->setEnabled(false);