aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-01-15 17:06:36 +0000
committersaturneric <[email protected]>2024-01-15 17:08:48 +0000
commit5af14839b718896ed8049d52ab60601ea1291db9 (patch)
tree2be9bf07932f2fd21b9759c87036f8c47345ce75
parentrefactor: remove libicu from project (diff)
downloadGpgFrontend-5af14839b718896ed8049d52ab60601ea1291db9.tar.gz
GpgFrontend-5af14839b718896ed8049d52ab60601ea1291db9.zip
fix: remove low level api setjmp to improve corss-platform ability
-rw-r--r--src/app.cpp40
-rw-r--r--src/init.h7
-rw-r--r--src/main.cpp7
-rw-r--r--src/signal.cpp37
4 files changed, 5 insertions, 86 deletions
diff --git a/src/app.cpp b/src/app.cpp
index d079adb3..0aa6e5d1 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -26,8 +26,6 @@
*
*/
-#include <csetjmp>
-
#include "GpgFrontendContext.h"
#include "core/GpgConstants.h"
#include "core/GpgCoreInit.h"
@@ -37,15 +35,6 @@
// main
#include "main.h"
-/**
- * \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
-
namespace GpgFrontend {
constexpr int kCrashCode = ~0; ///<
@@ -80,30 +69,11 @@ auto StartApplication(const GFCxtWPtr& p_ctx) -> int {
int restart_count = 0;
do {
-#ifndef WINDOWS
- int r = sigsetjmp(recover_env, 1);
-#else
- int r = setjmp(recover_env);
-#endif
- if (!r) {
- // after that load ui totally
- GpgFrontend::UI::InitGpgFrontendUI(app);
-
- // finally create main window
- return_from_event_loop_code = GpgFrontend::UI::RunGpgFrontendUI(app);
- } else {
- GF_MAIN_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 = kCrashCode;
- }
+ // after that load ui totally
+ GpgFrontend::UI::InitGpgFrontendUI(app);
+
+ // finally create main window
+ return_from_event_loop_code = GpgFrontend::UI::RunGpgFrontendUI(app);
GF_MAIN_LOG_DEBUG("try to destroy modules system and core");
diff --git a/src/init.h b/src/init.h
index a8d3bb9b..1481b435 100644
--- a/src/init.h
+++ b/src/init.h
@@ -33,13 +33,6 @@
namespace GpgFrontend {
/**
- * @brief handle the signal SIGSEGV
- *
- * @param sig
- */
-void HandleSignal(int sig);
-
-/**
* @brief
*
* @param args
diff --git a/src/main.cpp b/src/main.cpp
index 700e304e..eea2e9f6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -45,13 +45,6 @@
* @return
*/
auto main(int argc, char* argv[]) -> int {
-#ifdef RELEASE
- // re
- signal(SIGSEGV, HandleSignal);
- signal(SIGFPE, HandleSignal);
- signal(SIGILL, HandleSignal);
-#endif
-
GpgFrontend::GFCxtSPtr ctx =
GpgFrontend::SecureCreateSharedObject<GpgFrontend::GpgFrontendContext>(
argc, argv);
diff --git a/src/signal.cpp b/src/signal.cpp
index 8c934166..7722c36f 100644
--- a/src/signal.cpp
+++ b/src/signal.cpp
@@ -26,41 +26,4 @@
*
*/
-#include <csetjmp>
-#include <iostream>
-
#include "GpgFrontend.h"
-
-#ifdef FREEBSD
-extern sigjmp_buf recover_env;
-#else
-extern jmp_buf recover_env;
-#endif
-
-/**
- * @brief handle the signal caught.
- *
- * @param sig signal number
- */
-void HandleSignal(int sig) {
- static int _repeat_handle_num = 1, last_sig = sig;
- // GF_MAIN_LOG_DEBUG("signal caught {}", sig);
- std::cout << "signal caught" << sig;
-
- if (last_sig == sig)
- _repeat_handle_num++;
- else
- _repeat_handle_num = 1, last_sig = sig;
-
- if (_repeat_handle_num > 3) {
- std::cout << "The same signal appears three times,"
- << "execute the termination operation." << sig;
- exit(-1);
- }
-
-#ifndef WINDOWS
- siglongjmp(recover_env, 1);
-#else
- longjmp(recover_env, 1);
-#endif
-}