aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2022-12-04 10:15:50 +0000
committerSaturneric <[email protected]>2022-12-04 10:16:25 +0000
commit6bdfddb208bb00fc67a309b0c23af124217d3541 (patch)
treeb2fe2928b8ae7396021b433b808121260c6ef80f /src/main.cpp
parentfix: solve a refresh crash (diff)
downloadGpgFrontend-6bdfddb208bb00fc67a309b0c23af124217d3541.tar.gz
GpgFrontend-6bdfddb208bb00fc67a309b0c23af124217d3541.zip
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
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp61
1 files changed, 32 insertions, 29 deletions
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 <csignal>
#include <cstddef>
+#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