1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 12:12:50 +01:00

Qt: support fatal error as htmk

This commit is contained in:
Megamouse 2022-12-05 23:46:26 +01:00
parent ca0ca2e5a8
commit a6b44ea1bb
6 changed files with 21 additions and 25 deletions

View File

@ -96,7 +96,7 @@ thread_local bool g_tls_access_violation_recovered = false;
extern thread_local std::string(*g_tls_log_prefix)(); extern thread_local std::string(*g_tls_log_prefix)();
// Report error and call std::abort(), defined in main.cpp // Report error and call std::abort(), defined in main.cpp
[[noreturn]] void report_fatal_error(std::string_view); [[noreturn]] void report_fatal_error(std::string_view, bool = false);
std::string dump_useful_thread_info() std::string dump_useful_thread_info()
{ {

View File

@ -93,7 +93,7 @@ thread_local std::string_view g_tls_serialize_name;
extern thread_local std::string(*g_tls_log_prefix)(); extern thread_local std::string(*g_tls_log_prefix)();
// Report error and call std::abort(), defined in main.cpp // Report error and call std::abort(), defined in main.cpp
[[noreturn]] void report_fatal_error(std::string_view); [[noreturn]] void report_fatal_error(std::string_view, bool = false);
void initialize_timebased_time(u64 timebased_init, bool reset = false); void initialize_timebased_time(u64 timebased_init, bool reset = false);

View File

@ -91,7 +91,7 @@ extern char **environ;
LOG_CHANNEL(sys_log, "SYS"); LOG_CHANNEL(sys_log, "SYS");
LOG_CHANNEL(q_debug, "QDEBUG"); LOG_CHANNEL(q_debug, "QDEBUG");
[[noreturn]] extern void report_fatal_error(std::string_view _text) [[noreturn]] extern void report_fatal_error(std::string_view _text, bool is_html = false)
{ {
#ifdef __linux__ #ifdef __linux__
extern void jit_announce(uptr, usz, std::string_view); extern void jit_announce(uptr, usz, std::string_view);
@ -151,9 +151,9 @@ LOG_CHANNEL(q_debug, "QDEBUG");
std::cerr << fmt::format("RPCS3: %s\n", text); std::cerr << fmt::format("RPCS3: %s\n", text);
} }
static auto show_report = [](std::string_view text) static auto show_report = [is_html](std::string_view text)
{ {
fatal_error_dialog dlg(text); fatal_error_dialog dlg(text, is_html);
dlg.exec(); dlg.exec();
}; };

View File

@ -11,7 +11,7 @@
#include <Utilities/StrUtil.h> #include <Utilities/StrUtil.h>
#include <Utilities/StrFmt.h> #include <Utilities/StrFmt.h>
[[noreturn]] void report_fatal_error(std::string_view); [[noreturn]] void report_fatal_error(std::string_view, bool);
// Validates that system modules are properly installed // Validates that system modules are properly installed
// Only relevant for WIN32 // Only relevant for WIN32
@ -53,16 +53,18 @@ class WIN32_module_verifier
if (s.find(system_root) != 0) if (s.find(system_root) != 0)
{ {
const auto error_message = fmt::format( const auto error_message = fmt::format(
"The module '%s' was incorrectly installed.\n" "<p>"
"This module is part of the '%s' package.\n" "The module '%s' was incorrectly installed.<br>"
"You can install this package from this URL:\n" "This module is part of the '%s' package.<br>"
"<a href='%s'>%s</a>", "You can install this package from this URL:<br>"
"<a href='%s'>%s</a>"
"</p>",
wchar_to_utf8(module.name), wchar_to_utf8(module.name),
module.package_name, module.package_name,
module.dl_link, module.dl_link,
module.dl_link module.dl_link
); );
report_fatal_error(error_message); report_fatal_error(error_message, true);
} }
} }
} }

View File

@ -4,19 +4,10 @@
#include <QTextDocument> #include <QTextDocument>
#include <QIcon> #include <QIcon>
static QString process_dialog_text(std::string_view text) fatal_error_dialog::fatal_error_dialog(std::string_view text, bool is_html) : QMessageBox()
{ {
auto html = Qt::convertFromPlainText(QString::fromUtf8(text.data(), text.size())); const QString msg = QString::fromUtf8(text.data(), text.size());
// Let's preserve some html elements destroyed by convertFromPlainText
const QRegExp link_re{ R"(&lt;a\shref='([a-z0-9?=&#:\/\.\-]+)'&gt;([a-z0-9?=&#:\/\.\-]+)&lt;\/a&gt;)", Qt::CaseSensitive, QRegExp::RegExp2};
html = html.replace(link_re, "<a href=\\1>\\2</a>");
return html;
}
fatal_error_dialog::fatal_error_dialog(std::string_view text) : QMessageBox()
{
#ifndef __APPLE__ #ifndef __APPLE__
setWindowIcon(QIcon(":/rpcs3.ico")); setWindowIcon(QIcon(":/rpcs3.ico"));
#endif #endif
@ -24,14 +15,17 @@ fatal_error_dialog::fatal_error_dialog(std::string_view text) : QMessageBox()
setIcon(QMessageBox::Icon::Critical); setIcon(QMessageBox::Icon::Critical);
setTextFormat(Qt::TextFormat::RichText); setTextFormat(Qt::TextFormat::RichText);
setText(QString(R"( setText(QString(R"(
<p style="white-space: nowrap;"> <style>
p {white-space: nowrap;}
</style>
<p>
%1<br> %1<br>
%2<br> %2<br>
<a href='https://github.com/RPCS3/rpcs3/wiki/How-to-ask-for-Support'>https://github.com/RPCS3/rpcs3/wiki/How-to-ask-for-Support</a><br> <a href='https://github.com/RPCS3/rpcs3/wiki/How-to-ask-for-Support'>https://github.com/RPCS3/rpcs3/wiki/How-to-ask-for-Support</a><br>
%3<br> %3<br>
</p> </p>
)") )")
.arg(process_dialog_text(text)) .arg(is_html ? msg : Qt::convertFromPlainText(msg))
.arg(tr("HOW TO REPORT ERRORS:")) .arg(tr("HOW TO REPORT ERRORS:"))
.arg(tr("Please, don't send incorrect reports. Thanks for understanding."))); .arg(tr("Please, don't send incorrect reports. Thanks for understanding.")));
layout()->setSizeConstraint(QLayout::SetFixedSize); layout()->setSizeConstraint(QLayout::SetFixedSize);

View File

@ -9,5 +9,5 @@ class fatal_error_dialog : public QMessageBox
Q_OBJECT Q_OBJECT
public: public:
explicit fatal_error_dialog(std::string_view text); explicit fatal_error_dialog(std::string_view text, bool is_html);
}; };