From e4ea133717a5292339c134160da984ba186d3de8 Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 28 Apr 2015 19:03:01 -0400 Subject: Qt: Restructured to remove unnecessary shutdown event and various cleanups. --- src/citra_qt/main.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src/citra_qt/main.cpp') diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 5441c17f..dd180baa 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -199,10 +199,6 @@ void GMainWindow::OnDisplayTitleBars(bool show) void GMainWindow::BootGame(std::string filename) { LOG_INFO(Frontend, "Citra starting...\n"); - // Shutdown previous session if the emu thread is still active... - if (emu_thread != nullptr) - ShutdownGame(); - System::Init(render_window); // Load a game or die... @@ -222,29 +218,36 @@ void GMainWindow::BootGame(std::string filename) { } void GMainWindow::ShutdownGame() { - emu_thread->SetCpuRunning(false); - - emu_thread->ShutdownCpu(); - emu_thread->WaitForCpuShutdown(); - emu_thread->Stop(); - + // Shutdown the emulation thread and wait for it to complete + emu_thread->SetRunning(false); + emu_thread->Shutdown(); + emu_thread->wait(); delete emu_thread; emu_thread = nullptr; + // Release emu threads from any breakpoints + Pica::g_debug_context->ClearBreakpoints(); + + // Shutdown the core emulation System::Shutdown(); + // Update the GUI ui.action_Start->setEnabled(true); ui.action_Pause->setEnabled(false); ui.action_Stop->setEnabled(false); - render_window->hide(); } void GMainWindow::OnMenuLoadFile() { QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), QString(), tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.bin *.cci *.cxi)")); - if (filename.size()) - BootGame(filename.toLatin1().data()); + if (filename.size()) { + // Shutdown previous session if the emu thread is still active... + if (emu_thread != nullptr) + ShutdownGame(); + + BootGame(filename.toLatin1().data()); + } } void GMainWindow::OnMenuLoadSymbolMap() { @@ -255,7 +258,7 @@ void GMainWindow::OnMenuLoadSymbolMap() { void GMainWindow::OnStartGame() { - emu_thread->SetCpuRunning(true); + emu_thread->SetRunning(true); ui.action_Start->setEnabled(false); ui.action_Pause->setEnabled(true); @@ -264,7 +267,7 @@ void GMainWindow::OnStartGame() void GMainWindow::OnPauseGame() { - emu_thread->SetCpuRunning(false); + emu_thread->SetRunning(false); ui.action_Start->setEnabled(true); ui.action_Pause->setEnabled(false); -- cgit v1.2.3