From f27c8eb1b4c48031aa051aec57ffb8f47a104a54 Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 22 Sep 2019 16:14:16 +0200 Subject: [PATCH] fixed crash restart conditions --- chatterino.pro | 5 +++++ src/RunGui.cpp | 24 ++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/chatterino.pro b/chatterino.pro index 56857ea0a..3c016fcaf 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -39,6 +39,11 @@ macx { LIBS += -L/usr/local/lib } +# Set C_DEBUG if it's a debug build +CONFIG(debug, debug|release) { + DEFINES += C_DEBUG +} + # Submodules include(lib/warnings.pri) include(lib/appbase.pri) diff --git a/src/RunGui.cpp b/src/RunGui.cpp index 332a6f265..523a3c9fa 100644 --- a/src/RunGui.cpp +++ b/src/RunGui.cpp @@ -114,16 +114,14 @@ namespace { { using namespace std::chrono_literals; - // if (std::chrono::steady_clock::now() - signalsInitTime > 30s) - // { - QProcess proc; - proc.setProgram(QApplication::applicationFilePath()); - proc.setArguments({"--crash-recovery"}); - proc.startDetached(); - - // QProcess::startDetached(QApplication::applicationFilePath(), - // {"--crash-recovery"}); - // } + if (restartOnSignal && + std::chrono::steady_clock::now() - signalsInitTime > 30s) + { + QProcess proc; + proc.setProgram(QApplication::applicationFilePath()); + proc.setArguments({"--crash-recovery"}); + proc.startDetached(); + } _exit(signum); } @@ -132,13 +130,11 @@ namespace { // true. void initSignalHandler() { - //#if not defined(DEBUG) && not defined(_DEBUG) && not defined(NDEBUG) +#ifndef C_DEBUG signalsInitTime = std::chrono::steady_clock::now(); - // signal(SIGINT, handleSignal); signal(SIGSEGV, handleSignal); - // signal(SIGABRT_COMPAT, handleSignal); - //#endif +#endif } } // namespace