diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 2e9392d48..398c1d506 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -588,8 +588,7 @@ void MainWindow::onSystemDestroyed() // If we're closing or in batch mode, quit the whole application now. if (m_is_closing || QtHost::InBatchMode()) { - QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 1); - QCoreApplication::quit(); + quit(); return; } @@ -701,6 +700,22 @@ std::string MainWindow::getDeviceDiscPath(const QString& title) return ret; } +void MainWindow::quit() +{ + // Make sure VM is gone. It really should be if we're here. + if (s_system_valid) + { + g_emu_thread->shutdownSystem(false); + while (s_system_valid) + QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 1); + } + + // Ensure subwindows are removed before quitting. That way the log window cancelling + // the close event won't cancel the quit process. + destroySubWindows(); + QGuiApplication::quit(); +} + void MainWindow::recreate() { const bool was_display_created = m_display_created; @@ -2786,7 +2801,7 @@ void MainWindow::requestExit(bool allow_confirm /* = true */) if (s_system_valid) m_is_closing = true; else - QGuiApplication::quit(); + quit(); } void MainWindow::checkForSettingChanges() diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index a2d771bdf..732f855c8 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -87,6 +87,9 @@ public: /// Locks the system by pausing it, while a popup dialog is displayed. SystemLock pauseAndLockSystem(); + /// Force quits the application. + void quit(); + /// Accessors for the status bar widgets, updated by the emulation thread. ALWAYS_INLINE QLabel* getStatusRendererWidget() const { return m_status_renderer_widget; } ALWAYS_INLINE QLabel* getStatusResolutionWidget() const { return m_status_resolution_widget; }