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)
*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);
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -8,6 +8,7 @@
#include <memory>
#include <array>
#include <atomic>
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();