diff options
Diffstat (limited to '')
-rw-r--r-- | src/main.cpp | 67 |
1 files changed, 38 insertions, 29 deletions
diff --git a/src/main.cpp b/src/main.cpp index b51c44ea..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" @@ -46,7 +47,11 @@ INITIALIZE_EASYLOGGINGPP /** * \brief Store the jump buff and make it possible to recover from a crash. */ +#ifdef FREEBSD +sigjmp_buf recover_env; +#else jmp_buf recover_env; +#endif constexpr int CRASH_CODE = ~0; ///< @@ -76,10 +81,12 @@ extern void init_logging_system(); * @return */ int main(int argc, char* argv[]) { +#ifdef RELEASE // re signal(SIGSEGV, handle_signal); signal(SIGFPE, handle_signal); signal(SIGILL, handle_signal); +#endif // clean something before exit atexit(before_exit); @@ -104,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 |