Qt: Open a message box for Qt frontend errors

This commit is contained in:
Vicki Pfau 2019-05-04 16:03:18 -07:00
parent 46c135b4f9
commit 4dbebe8702
3 changed files with 11 additions and 0 deletions

View File

@ -52,6 +52,7 @@ Misc:
- GBA BIOS: Add timings for HLE BIOS math functions (fixes mgba.io/i/1396) - GBA BIOS: Add timings for HLE BIOS math functions (fixes mgba.io/i/1396)
- Debugger: Make tracing compatible with breakpoints/watchpoints - Debugger: Make tracing compatible with breakpoints/watchpoints
- Debugger: Print breakpoint/watchpoint number when inserting - Debugger: Print breakpoint/watchpoint number when inserting
- Qt: Open a message box for Qt frontend errors
0.7.1: (2019-02-24) 0.7.1: (2019-02-24)
Bugfixes: Bugfixes:

View File

@ -5,11 +5,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "LogController.h" #include "LogController.h"
#include <QMessageBox>
#include "ConfigController.h" #include "ConfigController.h"
using namespace QGBA; using namespace QGBA;
LogController LogController::s_global(mLOG_ALL); LogController LogController::s_global(mLOG_ALL);
int LogController::s_qtCat{-1};
LogController::LogController(int levels, QObject* parent) LogController::LogController(int levels, QObject* parent)
: 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, "gba.bios", mLOG_STUB | mLOG_FATAL);
mLogFilterSet(&m_filter, "core.status", mLOG_ALL & ~mLOG_DEBUG); mLogFilterSet(&m_filter, "core.status", mLOG_ALL & ~mLOG_DEBUG);
m_filter.defaultLevels = levels; m_filter.defaultLevels = levels;
s_qtCat = mLogCategoryById("platform.qt");
if (this != &s_global) { if (this != &s_global) {
connect(&s_global, &LogController::logPosted, this, &LogController::postLog); 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; *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); emit logPosted(level, category, string);
} }

View File

@ -85,6 +85,7 @@ private:
std::unique_ptr<QTextStream> m_logStream; std::unique_ptr<QTextStream> m_logStream;
static LogController s_global; static LogController s_global;
static int s_qtCat;
}; };
#define LOG(C, L) (*LogController::global())(mLOG_ ## L, _mLOG_CAT_ ## C) #define LOG(C, L) (*LogController::global())(mLOG_ ## L, _mLOG_CAT_ ## C)