From 28df8dbfeb17cf5a002a5504a6bd2ba5091bf07c Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 16 Apr 2015 23:31:14 -0400 Subject: Qt: Create emu thread on bootup, kill it on shutdown. --- src/citra_qt/main.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/citra_qt/main.cpp') diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 9f9ebc91..fe1dac62 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -57,7 +57,6 @@ GMainWindow::GMainWindow() : emu_thread(nullptr) render_window = new GRenderWindow(this, *this); render_window->hide(); - emu_thread = new EmuThread(render_window); profilerWidget = new ProfilerWidget(this); addDockWidget(Qt::BottomDockWidgetArea, profilerWidget); @@ -197,9 +196,9 @@ void GMainWindow::OnDisplayTitleBars(bool show) } } -void GMainWindow::BootGame(std::string filename) -{ +void GMainWindow::BootGame(std::string filename) { LOG_INFO(Frontend, "Citra starting...\n"); + System::Init(render_window); // Load a game or die... @@ -211,6 +210,7 @@ void GMainWindow::BootGame(std::string filename) registersWidget->OnDebugModeEntered(); callstackWidget->OnDebugModeEntered(); + emu_thread = new EmuThread(render_window); emu_thread->start(); render_window->show(); @@ -248,14 +248,22 @@ void GMainWindow::OnPauseGame() ui.action_Stop->setEnabled(true); } -void GMainWindow::OnStopGame() -{ +void GMainWindow::OnStopGame() { emu_thread->SetCpuRunning(false); - // TODO: Shutdown core + + emu_thread->ShutdownCpu(); + emu_thread->WaitForCpuShutdown(); + emu_thread->Stop(); + + delete emu_thread; + + System::Shutdown(); ui.action_Start->setEnabled(true); ui.action_Pause->setEnabled(false); ui.action_Stop->setEnabled(false); + + render_window->hide(); } void GMainWindow::OnOpenHotkeysDialog() -- cgit v1.2.3