feat: restart profile after core crash

This commit is contained in:
arm64v8a
2022-10-18 17:15:49 +08:00
parent b46cd2da3d
commit 2e991b675d
6 changed files with 35 additions and 7 deletions

View File

@@ -90,19 +90,22 @@ namespace NekoRay::sys {
if (!dataStore->core_prepare_exit && state == QProcess::NotRunning) {
if (failed_to_start) return; // no retry
restart_id = NekoRay::dataStore->started_id;
dialog_message("ExternalProcess", "Crashed");
showLog("[Error] core exited, restarting.\n");
// Restart
auto t = new QTimer;
connect(t, &QTimer::timeout, this, [=] {
setTimeout([=] {
Kill();
ExternalProcess::started = false;
Start();
t->deleteLater();
});
t->setSingleShot(true);
t->setInterval(1000);
t->start();
}, this, 1000);
} else if (state == QProcess::Running && restart_id >= 0) {
// Restart profile
setTimeout([=] {
dialog_message("ExternalProcess", "CoreRestarted," + Int2String(restart_id));
restart_id = -1;
}, this, 1000);
}
});
}