added manual crash trigger for handling testing
This commit is contained in:
+16
-1
@@ -169,6 +169,20 @@ void Core::Start()
|
||||
qInfo() << "Headless pre-cache is not fully implemented yet";
|
||||
break;
|
||||
}
|
||||
|
||||
// Manual crash triggering
|
||||
if (core_params_.crash_on_startup()) {
|
||||
const int interval = 5000;
|
||||
qInfo() << "Manual crash was triggered. Application will crash in" << interval << "ms";
|
||||
QTimer *crash_timer = new QTimer(this);
|
||||
crash_timer->setInterval(interval);
|
||||
connect(crash_timer, &QTimer::timeout, this, []{
|
||||
// Try to read invalid memory to crash the application
|
||||
int *invalid_ptr = nullptr;
|
||||
qDebug() << *invalid_ptr;
|
||||
});
|
||||
crash_timer->start();
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Stop()
|
||||
@@ -1628,7 +1642,8 @@ void Core::OpenProject()
|
||||
|
||||
Core::CoreParams::CoreParams() :
|
||||
mode_(kRunNormal),
|
||||
run_fullscreen_(false)
|
||||
run_fullscreen_(false),
|
||||
crash_(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+12
@@ -104,6 +104,16 @@ public:
|
||||
startup_language_ = s;
|
||||
}
|
||||
|
||||
bool crash_on_startup() const
|
||||
{
|
||||
return crash_;
|
||||
}
|
||||
|
||||
void set_crash_on_startup(bool e)
|
||||
{
|
||||
crash_ = true;
|
||||
}
|
||||
|
||||
private:
|
||||
RunMode mode_;
|
||||
|
||||
@@ -113,6 +123,8 @@ public:
|
||||
|
||||
bool run_fullscreen_;
|
||||
|
||||
bool crash_;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -133,6 +133,9 @@ int main(int argc, char *argv[])
|
||||
parser.AddOption({QStringLiteral("stylesheet")}, QString(), true, QString(), true);
|
||||
parser.AddOption({QStringLiteral("widgetcount")}, QString(), false, QString(), true);
|
||||
|
||||
// Hidden crash option for debugging the crash handling
|
||||
auto crash_option = parser.AddOption({QStringLiteral("-crash")}, QString(), true, QString(), true);
|
||||
|
||||
parser.Process(argc, argv);
|
||||
|
||||
if (help_option->IsSet()) {
|
||||
@@ -159,6 +162,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (crash_option->IsSet()) {
|
||||
startup_params.set_crash_on_startup(true);
|
||||
}
|
||||
|
||||
startup_params.set_fullscreen(fullscreen_option->IsSet());
|
||||
|
||||
startup_params.set_startup_project(project_argument->GetSetting());
|
||||
|
||||
Reference in New Issue
Block a user