2023-12-24 15:38:58 +01:00
|
|
|
#include "widgets/dialogs/LastRunCrashDialog.hpp"
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2023-12-24 15:38:58 +01:00
|
|
|
#include "common/Args.hpp"
|
|
|
|
#include "common/Literals.hpp"
|
|
|
|
#include "common/Modes.hpp"
|
|
|
|
#include "singletons/Paths.hpp"
|
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories
In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:
In ChatterSet.hpp, I changed lrucache to a <>include
In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00
|
|
|
#include "util/LayoutCreator.hpp"
|
|
|
|
|
2023-12-24 15:38:58 +01:00
|
|
|
#include <QDesktopServices>
|
2018-06-01 14:20:46 +02:00
|
|
|
#include <QDialogButtonBox>
|
2023-12-24 15:38:58 +01:00
|
|
|
#include <QDir>
|
2018-06-01 14:20:46 +02:00
|
|
|
#include <QLabel>
|
2023-12-24 15:38:58 +01:00
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QProcess>
|
2018-06-01 14:20:46 +02:00
|
|
|
#include <QPushButton>
|
2023-12-24 15:38:58 +01:00
|
|
|
#include <QRandomGenerator>
|
|
|
|
#include <QStringBuilder>
|
2018-04-20 00:15:57 +02:00
|
|
|
#include <QVBoxLayout>
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2023-12-24 15:38:58 +01:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
using namespace chatterino::literals;
|
|
|
|
|
|
|
|
const std::initializer_list<QString> MESSAGES = {
|
|
|
|
u"Oops..."_s, u"NotLikeThis"_s,
|
|
|
|
u"NOOOOOO"_s, u"I'm sorry"_s,
|
|
|
|
u"We're sorry"_s, u"My bad"_s,
|
|
|
|
u"FailFish"_s, u"O_o"_s,
|
|
|
|
u"Sorry :("_s, u"I blame cosmic rays"_s,
|
|
|
|
u"I blame TMI"_s, u"I blame Helix"_s,
|
|
|
|
u"Oopsie woopsie"_s,
|
|
|
|
};
|
|
|
|
|
|
|
|
QString randomMessage()
|
|
|
|
{
|
|
|
|
return *(MESSAGES.begin() +
|
|
|
|
(QRandomGenerator::global()->generate64() % MESSAGES.size()));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2018-04-20 00:15:57 +02:00
|
|
|
namespace chatterino {
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2023-12-24 15:38:58 +01:00
|
|
|
using namespace literals;
|
|
|
|
|
2024-01-16 21:56:43 +01:00
|
|
|
LastRunCrashDialog::LastRunCrashDialog(const Args &args, const Paths &paths)
|
2018-04-20 00:15:57 +02:00
|
|
|
{
|
2018-06-01 14:20:46 +02:00
|
|
|
this->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
2023-12-24 15:38:58 +01:00
|
|
|
this->setWindowTitle(u"Chatterino - " % randomMessage());
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-06-26 17:06:17 +02:00
|
|
|
auto layout =
|
|
|
|
LayoutCreator<LastRunCrashDialog>(this).setLayoutType<QVBoxLayout>();
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2023-12-24 15:38:58 +01:00
|
|
|
QString text =
|
|
|
|
u"Chatterino unexpectedly crashed and restarted. "_s
|
|
|
|
"<i>You can disable automatic restarts in the settings.</i><br><br>";
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2023-12-24 15:38:58 +01:00
|
|
|
#ifdef CHATTERINO_WITH_CRASHPAD
|
2024-01-16 21:56:43 +01:00
|
|
|
auto reportsDir = QDir(paths.crashdumpDirectory).filePath(u"reports"_s);
|
2023-12-24 15:38:58 +01:00
|
|
|
text += u"A <b>crash report</b> has been saved to "
|
|
|
|
"<a href=\"file:///" %
|
|
|
|
reportsDir % u"\">" % reportsDir % u"</a>.<br>";
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2023-12-29 15:40:31 +01:00
|
|
|
if (args.exceptionCode)
|
2023-12-24 15:38:58 +01:00
|
|
|
{
|
|
|
|
text += u"The last run crashed with code <code>0x" %
|
2023-12-29 15:40:31 +01:00
|
|
|
QString::number(*args.exceptionCode, 16) % u"</code>";
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2023-12-29 15:40:31 +01:00
|
|
|
if (args.exceptionMessage)
|
2023-12-24 15:38:58 +01:00
|
|
|
{
|
2023-12-29 15:40:31 +01:00
|
|
|
text += u" (" % *args.exceptionMessage % u")";
|
2023-12-24 15:38:58 +01:00
|
|
|
}
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2023-12-24 15:38:58 +01:00
|
|
|
text += u".<br>"_s;
|
|
|
|
}
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2023-12-24 15:38:58 +01:00
|
|
|
text +=
|
|
|
|
"Crash reports are <b>only stored locally</b> and never uploaded.<br>"
|
|
|
|
"<br>Please <a "
|
|
|
|
"href=\"https://github.com/Chatterino/chatterino2/issues/new\">report "
|
|
|
|
"the crash</a> "
|
|
|
|
u"so it can be prevented in the future."_s;
|
|
|
|
|
|
|
|
if (Modes::instance().isNightly)
|
|
|
|
{
|
|
|
|
text += u" Make sure you're using the latest nightly version!"_s;
|
|
|
|
}
|
|
|
|
|
|
|
|
text +=
|
|
|
|
u"<br>For more information, <a href=\"https://wiki.chatterino.com/Crash%20Analysis/\">consult the wiki</a>."_s;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
auto label = layout.emplace<QLabel>(text);
|
|
|
|
label->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
|
|
|
label->setOpenExternalLinks(true);
|
|
|
|
label->setWordWrap(true);
|
|
|
|
|
|
|
|
layout->addSpacing(16);
|
|
|
|
|
|
|
|
auto buttons = layout.emplace<QDialogButtonBox>();
|
|
|
|
|
|
|
|
auto *okButton = buttons->addButton(u"Ok"_s, QDialogButtonBox::AcceptRole);
|
2020-11-08 12:02:19 +01:00
|
|
|
QObject::connect(okButton, &QPushButton::clicked, [this] {
|
|
|
|
this->accept();
|
|
|
|
});
|
2018-04-20 00:15:57 +02:00
|
|
|
}
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2018-04-20 00:15:57 +02:00
|
|
|
} // namespace chatterino
|