From 4dbebe870295b1d222f9df9672c2aa614ebda418 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 4 May 2019 16:03:18 -0700 Subject: [PATCH] Qt: Open a message box for Qt frontend errors --- CHANGES | 1 + src/platform/qt/LogController.cpp | 9 +++++++++ src/platform/qt/LogController.h | 1 + 3 files changed, 11 insertions(+) diff --git a/CHANGES b/CHANGES index d8d768e2d..4cd280434 100644 --- a/CHANGES +++ b/CHANGES @@ -52,6 +52,7 @@ Misc: - GBA BIOS: Add timings for HLE BIOS math functions (fixes mgba.io/i/1396) - Debugger: Make tracing compatible with breakpoints/watchpoints - Debugger: Print breakpoint/watchpoint number when inserting + - Qt: Open a message box for Qt frontend errors 0.7.1: (2019-02-24) Bugfixes: diff --git a/src/platform/qt/LogController.cpp b/src/platform/qt/LogController.cpp index 5ad220ad6..e6f80e0b1 100644 --- a/src/platform/qt/LogController.cpp +++ b/src/platform/qt/LogController.cpp @@ -5,11 +5,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "LogController.h" +#include + #include "ConfigController.h" using namespace QGBA; LogController LogController::s_global(mLOG_ALL); +int LogController::s_qtCat{-1}; LogController::LogController(int levels, QObject* parent) : QObject(parent) @@ -18,6 +21,7 @@ LogController::LogController(int levels, QObject* parent) mLogFilterSet(&m_filter, "gba.bios", mLOG_STUB | mLOG_FATAL); mLogFilterSet(&m_filter, "core.status", mLOG_ALL & ~mLOG_DEBUG); m_filter.defaultLevels = levels; + s_qtCat = mLogCategoryById("platform.qt"); if (this != &s_global) { connect(&s_global, &LogController::logPosted, this, &LogController::postLog); @@ -65,6 +69,11 @@ void LogController::postLog(int level, int category, const QString& string) { *m_logStream << line << endl; } } + if (category == s_qtCat && level == mLOG_ERROR && this == &s_global) { + QMessageBox* dialog = new QMessageBox(QMessageBox::Critical, tr("An error occurred"), string, QMessageBox::Ok); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); + } emit logPosted(level, category, string); } diff --git a/src/platform/qt/LogController.h b/src/platform/qt/LogController.h index a06f7bf47..548be8b4d 100644 --- a/src/platform/qt/LogController.h +++ b/src/platform/qt/LogController.h @@ -85,6 +85,7 @@ private: std::unique_ptr m_logStream; static LogController s_global; + static int s_qtCat; }; #define LOG(C, L) (*LogController::global())(mLOG_ ## L, _mLOG_CAT_ ## C)