Use Qt for error reports

This commit is contained in:
Nekotekina 2017-11-23 18:37:08 +03:00
parent cc4bc41cf4
commit 7d3a528871
5 changed files with 77 additions and 35 deletions

View file

@ -5,19 +5,65 @@
#include <QCommandLineParser>
#include <QFileInfo>
#include <QTimer>
#include <QObject>
#include "rpcs3_app.h"
#include "Utilities/sema.h"
#ifdef _WIN32
#include <windows.h>
#endif
inline std::string sstr(const QString& _in) { return _in.toUtf8().toStdString(); }
template <typename... Args>
inline auto tr(Args&&... args)
{
return QObject::tr(std::forward<Args>(args)...);
}
namespace logs
{
void set_init();
}
static semaphore<> s_init{0};
static semaphore<> s_qt_init{0};
static semaphore<> s_qt_mutex{};
[[noreturn]] extern void report_fatal_error(const std::string& text)
{
s_qt_mutex.wait();
if (!s_qt_init.try_wait())
{
s_init.wait();
static int argc = 1;
static char arg1[] = {"ERROR"};
static char* argv[] = {arg1};
static QApplication app0{argc, argv};
}
QMessageBox msg;
msg.setWindowTitle(tr("RPCS3: Fatal Error"));
msg.setIcon(QMessageBox::Critical);
msg.setTextFormat(Qt::RichText);
msg.setText(QString(R"(
<p style="white-space: nowrap;">
%1<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>
%3<br>
</p>
)")
.arg(Qt::convertFromPlainText(QString::fromStdString(text)))
.arg(tr("HOW TO REPORT ERRORS:"))
.arg(tr("Please, don't send incorrect reports. Thanks for understanding.")));
msg.layout()->setSizeConstraint(QLayout::SetFixedSize);
msg.exec();
std::abort();
}
int main(int argc, char** argv)
{
logs::set_init();
@ -41,6 +87,8 @@ int main(int argc, char** argv)
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
s_init.post();
s_qt_mutex.wait();
rpcs3_app app(argc, argv);
// Command line args
@ -79,5 +127,7 @@ int main(int argc, char** argv)
});
}
s_qt_init.post();
s_qt_mutex.post();
return app.exec();
}