diff --git a/Source/Core/DolphinQt/Main.cpp b/Source/Core/DolphinQt/Main.cpp index 289fbeedc0..4719de7051 100644 --- a/Source/Core/DolphinQt/Main.cpp +++ b/Source/Core/DolphinQt/Main.cpp @@ -60,6 +60,7 @@ int main(int argc, char* argv[]) int retcode = app.exec(); delete g_main_window; + Core::Shutdown(); UICommon::Shutdown(); return retcode; } diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 3881dcd0c4..d597d17151 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -62,7 +63,9 @@ DMainWindow::DMainWindow(QWidget* parent_widget) StartGame(filename); }); connect(m_ui->actionBrowse, &QAction::triggered, this, &DMainWindow::OnBrowse); - connect(m_ui->actionExit, &QAction::triggered, this, &DMainWindow::OnExit); + connect(m_ui->actionExit, &QAction::triggered, this, [&]() { + close(); + }); connect(m_ui->actionListView, &QAction::triggered, this, &DMainWindow::OnGameListStyleChanged); connect(m_ui->actionTreeView, &QAction::triggered, this, &DMainWindow::OnGameListStyleChanged); @@ -110,7 +113,10 @@ DMainWindow::~DMainWindow() void DMainWindow::closeEvent(QCloseEvent* ce) { - Stop(); + if (!OnStop()) + ce->ignore(); + else + QMainWindow::closeEvent(ce); } // Emulation @@ -231,14 +237,6 @@ void DMainWindow::OnBrowse() m_game_tracker->ScanForGames(); } -void DMainWindow::OnExit() -{ - close(); - if (Core::GetState() == Core::CORE_UNINITIALIZED || m_isStopping) - return; - Stop(); -} - void DMainWindow::OnPlay() { if (Core::GetState() != Core::CORE_UNINITIALIZED) @@ -262,9 +260,17 @@ bool DMainWindow::OnStop() // Ask for confirmation in case the user accidentally clicked Stop / Escape if (SConfig::GetInstance().bConfirmStop) { - // Pause emulation - Core::SetState(Core::CORE_PAUSE); - emit CoreStateChanged(Core::CORE_PAUSE); + // Pause emulation if it isn't already + bool wasPaused = false; + if (Core::GetState() == Core::CORE_PAUSE) + { + wasPaused = true; + } + else + { + Core::SetState(Core::CORE_PAUSE); + emit CoreStateChanged(Core::CORE_PAUSE); + } QMessageBox::StandardButton ret = QMessageBox::question(m_render_widget.get(), tr("Please confirm..."), tr("Do you want to stop the current emulation?"), @@ -272,7 +278,8 @@ bool DMainWindow::OnStop() if (ret == QMessageBox::No) { - DoStartPause(); + if (!wasPaused) + DoStartPause(); return false; } } diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h index 0644d57d84..82492897b8 100644 --- a/Source/Core/DolphinQt/MainWindow.h +++ b/Source/Core/DolphinQt/MainWindow.h @@ -44,7 +44,6 @@ private slots: // Main toolbar void OnBrowse(); - void OnExit(); void OnPlay(); void OnReset(); diff --git a/Source/Core/DolphinQt/VideoInterface/RenderWidget.h b/Source/Core/DolphinQt/VideoInterface/RenderWidget.h index 3f6be38ff2..0afbf76f74 100644 --- a/Source/Core/DolphinQt/VideoInterface/RenderWidget.h +++ b/Source/Core/DolphinQt/VideoInterface/RenderWidget.h @@ -19,10 +19,7 @@ protected: void mousePressEvent(QMouseEvent*) override {} void paintEvent(QPaintEvent*) override {} -private slots: +private: void closeEvent(QCloseEvent* e) override; - -signals: - void Closed(); };