Improve report_fatal_error()

Previously it could cause secondary segfault on Linux.
This commit is contained in:
Nekotekina 2020-03-08 21:54:21 +03:00
parent c87beaa694
commit 6268a2d384

View file

@ -62,12 +62,14 @@ extern char **environ;
{ {
const bool local = s_qt_init.try_lock(); const bool local = s_qt_init.try_lock();
// Possibly created and assigned here
QScopedPointer<QCoreApplication> app;
if (local) if (local)
{ {
static int argc = 1; static int argc = 1;
static char arg1[] = {"ERROR"}; static char* argv[] = {+s_argv0};
static char* argv[] = {arg1}; app.reset(new QApplication{argc, argv});
static QApplication app0{argc, argv};
} }
if (!local) if (!local)
@ -94,7 +96,6 @@ extern char **environ;
.arg(tr("Please, don't send incorrect reports. Thanks for understanding."))); .arg(tr("Please, don't send incorrect reports. Thanks for understanding.")));
msg.layout()->setSizeConstraint(QLayout::SetFixedSize); msg.layout()->setSizeConstraint(QLayout::SetFixedSize);
msg.exec(); msg.exec();
std::exit(0);
}; };
#ifdef __APPLE__ #ifdef __APPLE__
@ -109,7 +110,10 @@ extern char **environ;
// If Qt is already initialized, spawn a new RPCS3 process with an --error argument // If Qt is already initialized, spawn a new RPCS3 process with an --error argument
if (local) if (local)
{ {
// Since we only show an error, we can hope for a graceful exit
show_report(text); show_report(text);
app.reset();
std::exit(0);
} }
else else
{ {
@ -139,10 +143,7 @@ extern char **environ;
} }
} }
while (true) std::abort();
{
std::this_thread::sleep_for(1s);
}
} }
struct pause_on_fatal final : logs::listener struct pause_on_fatal final : logs::listener