From d2ce14f9679dfd99fef52e451c3c24a4a7b2e876 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 26 Jun 2024 23:09:55 +0200 Subject: [PATCH] Fatals now work again. --- src/86box.c | 12 ++++++++---- src/chipset/intel_piix.c | 2 ++ src/qt/qt_mainwindow.cpp | 16 +++++++++++++--- src/qt/qt_mainwindow.hpp | 5 +++-- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/86box.c b/src/86box.c index 61b81bbf3..60423b2a1 100644 --- a/src/86box.c +++ b/src/86box.c @@ -354,12 +354,14 @@ fatal(const char *fmt, ...) if ((sp = strchr(temp, '\n')) != NULL) *sp = '\0'; + do_pause(2); + + ui_msgbox(MBX_ERROR | MBX_FATAL | MBX_ANSI, temp); + /* Cleanly terminate all of the emulator's components so as to avoid things like threads getting stuck. */ do_stop(); - ui_msgbox(MBX_ERROR | MBX_FATAL | MBX_ANSI, temp); - fflush(stdlog); exit(-1); @@ -396,12 +398,14 @@ fatal_ex(const char *fmt, va_list ap) if ((sp = strchr(temp, '\n')) != NULL) *sp = '\0'; + do_pause(2); + + ui_msgbox(MBX_ERROR | MBX_FATAL | MBX_ANSI, temp); + /* Cleanly terminate all of the emulator's components so as to avoid things like threads getting stuck. */ do_stop(); - ui_msgbox(MBX_ERROR | MBX_FATAL | MBX_ANSI, temp); - fflush(stdlog); } diff --git a/src/chipset/intel_piix.c b/src/chipset/intel_piix.c index 1f95c28b3..e76486917 100644 --- a/src/chipset/intel_piix.c +++ b/src/chipset/intel_piix.c @@ -243,6 +243,8 @@ smbus_update_io_mapping(piix_t *dev) static void nvr_update_io_mapping(piix_t *dev) { + return; + if (dev->nvr_io_base != 0x0000) { piix_log("Removing NVR at %04X...\n", dev->nvr_io_base); nvr_at_handler(0, dev->nvr_io_base, dev->nvr); diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 112d1cf23..0b7ebb33d 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -214,7 +214,7 @@ MainWindow::MainWindow(QWidget *parent) #endif }); - connect(this, &MainWindow::showMessageForNonQtThread, this, &MainWindow::showMessage_, Qt::BlockingQueuedConnection); + connect(this, &MainWindow::showMessageForNonQtThread, this, &MainWindow::showMessage_, Qt::QueuedConnection); connect(this, &MainWindow::setTitle, this, [this, toolbar_label](const QString &title) { if (dopause && !hide_tool_bar) { @@ -1267,13 +1267,20 @@ MainWindow::showMessage(int flags, const QString &header, const QString &message if (QThread::currentThread() == this->thread()) { showMessage_(flags, header, message); } else { - emit showMessageForNonQtThread(flags, header, message); + std::atomic_bool done = false; + emit showMessageForNonQtThread(flags, header, message, &done); + while (!done) { + QThread::msleep(1); + } } } void -MainWindow::showMessage_(int flags, const QString &header, const QString &message) +MainWindow::showMessage_(int flags, const QString &header, const QString &message, std::atomic_bool *done) { + if (done) { + *done = false; + } QMessageBox box(QMessageBox::Warning, header, message, QMessageBox::NoButton, this); if (flags & (MBX_FATAL)) { box.setIcon(QMessageBox::Critical); @@ -1282,6 +1289,9 @@ MainWindow::showMessage_(int flags, const QString &header, const QString &messag } box.setTextFormat(Qt::TextFormat::RichText); box.exec(); + if (done) { + *done = true; + } if (cpu_thread_run == 0) QApplication::exit(-1); } diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 1fca09231..175ef5b7e 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -8,6 +8,7 @@ #include #include +#include class MediaMenu; class RendererStack; @@ -54,7 +55,7 @@ signals: void setFullscreen(bool state); void setMouseCapture(bool state); - void showMessageForNonQtThread(int flags, const QString &header, const QString &message); + void showMessageForNonQtThread(int flags, const QString &header, const QString &message, std::atomic_bool* done); void getTitleForNonQtThread(wchar_t *title); public slots: void showSettings(); @@ -120,7 +121,7 @@ private slots: void on_actionRenderer_options_triggered(); void refreshMediaMenu(); - void showMessage_(int flags, const QString &header, const QString &message); + void showMessage_(int flags, const QString &header, const QString &message, std::atomic_bool* done = nullptr); void getTitle_(wchar_t *title); void on_actionMCA_devices_triggered();