Fatals now work again.

This commit is contained in:
OBattler
2024-06-26 23:09:55 +02:00
parent 6a0f869d8a
commit d2ce14f967
4 changed files with 26 additions and 9 deletions

View File

@@ -354,12 +354,14 @@ fatal(const char *fmt, ...)
if ((sp = strchr(temp, '\n')) != NULL) if ((sp = strchr(temp, '\n')) != NULL)
*sp = '\0'; *sp = '\0';
do_pause(2);
ui_msgbox(MBX_ERROR | MBX_FATAL | MBX_ANSI, temp);
/* Cleanly terminate all of the emulator's components so as /* Cleanly terminate all of the emulator's components so as
to avoid things like threads getting stuck. */ to avoid things like threads getting stuck. */
do_stop(); do_stop();
ui_msgbox(MBX_ERROR | MBX_FATAL | MBX_ANSI, temp);
fflush(stdlog); fflush(stdlog);
exit(-1); exit(-1);
@@ -396,12 +398,14 @@ fatal_ex(const char *fmt, va_list ap)
if ((sp = strchr(temp, '\n')) != NULL) if ((sp = strchr(temp, '\n')) != NULL)
*sp = '\0'; *sp = '\0';
do_pause(2);
ui_msgbox(MBX_ERROR | MBX_FATAL | MBX_ANSI, temp);
/* Cleanly terminate all of the emulator's components so as /* Cleanly terminate all of the emulator's components so as
to avoid things like threads getting stuck. */ to avoid things like threads getting stuck. */
do_stop(); do_stop();
ui_msgbox(MBX_ERROR | MBX_FATAL | MBX_ANSI, temp);
fflush(stdlog); fflush(stdlog);
} }

View File

@@ -243,6 +243,8 @@ smbus_update_io_mapping(piix_t *dev)
static void static void
nvr_update_io_mapping(piix_t *dev) nvr_update_io_mapping(piix_t *dev)
{ {
return;
if (dev->nvr_io_base != 0x0000) { if (dev->nvr_io_base != 0x0000) {
piix_log("Removing NVR at %04X...\n", dev->nvr_io_base); piix_log("Removing NVR at %04X...\n", dev->nvr_io_base);
nvr_at_handler(0, dev->nvr_io_base, dev->nvr); nvr_at_handler(0, dev->nvr_io_base, dev->nvr);

View File

@@ -214,7 +214,7 @@ MainWindow::MainWindow(QWidget *parent)
#endif #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) { connect(this, &MainWindow::setTitle, this, [this, toolbar_label](const QString &title) {
if (dopause && !hide_tool_bar) { if (dopause && !hide_tool_bar) {
@@ -1267,13 +1267,20 @@ MainWindow::showMessage(int flags, const QString &header, const QString &message
if (QThread::currentThread() == this->thread()) { if (QThread::currentThread() == this->thread()) {
showMessage_(flags, header, message); showMessage_(flags, header, message);
} else { } else {
emit showMessageForNonQtThread(flags, header, message); std::atomic_bool done = false;
emit showMessageForNonQtThread(flags, header, message, &done);
while (!done) {
QThread::msleep(1);
}
} }
} }
void 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); QMessageBox box(QMessageBox::Warning, header, message, QMessageBox::NoButton, this);
if (flags & (MBX_FATAL)) { if (flags & (MBX_FATAL)) {
box.setIcon(QMessageBox::Critical); box.setIcon(QMessageBox::Critical);
@@ -1282,6 +1289,9 @@ MainWindow::showMessage_(int flags, const QString &header, const QString &messag
} }
box.setTextFormat(Qt::TextFormat::RichText); box.setTextFormat(Qt::TextFormat::RichText);
box.exec(); box.exec();
if (done) {
*done = true;
}
if (cpu_thread_run == 0) if (cpu_thread_run == 0)
QApplication::exit(-1); QApplication::exit(-1);
} }

View File

@@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include <array> #include <array>
#include <atomic>
class MediaMenu; class MediaMenu;
class RendererStack; class RendererStack;
@@ -54,7 +55,7 @@ signals:
void setFullscreen(bool state); void setFullscreen(bool state);
void setMouseCapture(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); void getTitleForNonQtThread(wchar_t *title);
public slots: public slots:
void showSettings(); void showSettings();
@@ -120,7 +121,7 @@ private slots:
void on_actionRenderer_options_triggered(); void on_actionRenderer_options_triggered();
void refreshMediaMenu(); 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 getTitle_(wchar_t *title);
void on_actionMCA_devices_triggered(); void on_actionMCA_devices_triggered();