From 6bdfddb208bb00fc67a309b0c23af124217d3541 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Sun, 4 Dec 2022 18:15:50 +0800 Subject: feat(ui, core): add custom key db support 1. add custom key db support 2. add deep restart mode for custom key db settings 3. add core reset function --- src/main.cpp | 61 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 29 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 14563880..5f2ba02e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,6 +34,7 @@ #include #include +#include "core/GpgConstants.h" #include "core/GpgCoreInit.h" #include "ui/GpgFrontendApplication.h" #include "ui/GpgFrontendUIInit.h" @@ -110,38 +111,40 @@ int main(int argc, char* argv[]) { int return_from_event_loop_code; do { + do { #ifndef WINDOWS - int r = sigsetjmp(recover_env, 1); + int r = sigsetjmp(recover_env, 1); #else - int r = setjmp(recover_env); + int r = setjmp(recover_env); #endif - if (!r) { - // init ui library - GpgFrontend::UI::InitGpgFrontendUI(app); - - // create main window - return_from_event_loop_code = GpgFrontend::UI::RunGpgFrontendUI(app); - } else { - LOG(ERROR) << "recover from a crash"; - // when signal is caught, restart the main window - auto* message_box = new QMessageBox( - QMessageBox::Critical, _("A serious error has occurred"), - _("Oh no! GpgFrontend caught a serious error in the software, so " - "it needs to be restarted. If the problem recurs, please " - "manually terminate the program and report the problem to the " - "developer."), - QMessageBox::Ok, nullptr); - message_box->exec(); - return_from_event_loop_code = CRASH_CODE; - } - - if (return_from_event_loop_code == CRASH_CODE) { - app = GpgFrontend::UI::GpgFrontendApplication::GetInstance(argc, argv, - true); - } - - LOG(INFO) << "loop refresh"; - } while (return_from_event_loop_code == RESTART_CODE || + if (!r) { + // init ui library + GpgFrontend::UI::InitGpgFrontendUI(app); + + // create main window + return_from_event_loop_code = GpgFrontend::UI::RunGpgFrontendUI(app); + } else { + LOG(ERROR) << "recover from a crash"; + // when signal is caught, restart the main window + auto* message_box = new QMessageBox( + QMessageBox::Critical, _("A serious error has occurred"), + _("Oh no! GpgFrontend caught a serious error in the software, so " + "it needs to be restarted. If the problem recurs, please " + "manually terminate the program and report the problem to the " + "developer."), + QMessageBox::Ok, nullptr); + message_box->exec(); + return_from_event_loop_code = CRASH_CODE; + } + + LOG(INFO) << "loop refresh"; + } while (return_from_event_loop_code == RESTART_CODE); + + // reset core + GpgFrontend::ResetGpgFrontendCore(); + + // deep restart mode + } while (return_from_event_loop_code == DEEP_RESTART_CODE || return_from_event_loop_code == CRASH_CODE); // exit the program -- cgit v1.2.3