From 13d75c2e4f953b5966bc7e6dec168128e07286bc Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 24 Dec 2021 12:59:10 +0600 Subject: [PATCH] Close the main window after ACPI/APM shutdown --- src/qt/qt_mainwindow.cpp | 2 +- src/qt/qt_platform.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 6ea9f9c0f..d63c20668 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -270,7 +270,7 @@ MainWindow::MainWindow(QWidget *parent) : } void MainWindow::closeEvent(QCloseEvent *event) { - if (confirm_exit) + if (confirm_exit && cpu_thread_run) { QMessageBox questionbox(QMessageBox::Icon::Question, "86Box", "Are you sure you want to exit 86Box?", QMessageBox::Yes | QMessageBox::No, this); QCheckBox *chkbox = new QCheckBox("Do not ask me again"); diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index 8d30ab5df..9665c3a1b 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -16,12 +16,15 @@ #include #include +#include "qt_mainwindow.hpp" + #ifdef Q_OS_UNIX #include #endif // static QByteArray buf; extern QElapsedTimer elapsed_timer; +extern MainWindow* main_window; QElapsedTimer elapsed_timer; static std::atomic_int blitmx_contention = 0; @@ -355,6 +358,7 @@ plat_power_off(void) cycles -= 99999999; cpu_thread_run = 0; + main_window->close(); } void set_language(uint32_t id) {