mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 11:49:01 +03:00
parent
5c3c6b63ba
commit
7c35904062
1 changed files with 10 additions and 22 deletions
|
@ -36,11 +36,9 @@
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
#ifdef Q_OS_UNIX
|
||||||
#ifndef Q_OS_HAIKU
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#elif defined Q_OS_WIN
|
||||||
#elif defined DISABLE_GUI
|
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -51,7 +49,7 @@
|
||||||
#ifdef STACKTRACE
|
#ifdef STACKTRACE
|
||||||
#include "stacktrace.h"
|
#include "stacktrace.h"
|
||||||
|
|
||||||
#if defined Q_OS_WIN && !defined DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
#include "gui/stacktracedialog.h"
|
#include "gui/stacktracedialog.h"
|
||||||
#endif
|
#endif
|
||||||
#endif //STACKTRACE
|
#endif //STACKTRACE
|
||||||
|
@ -74,7 +72,6 @@ namespace
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !(defined Q_OS_WIN && !defined DISABLE_GUI) && !defined Q_OS_HAIKU
|
|
||||||
void safePrint(const char *str)
|
void safePrint(const char *str)
|
||||||
{
|
{
|
||||||
const size_t strLen = strlen(str);
|
const size_t strLen = strlen(str);
|
||||||
|
@ -86,14 +83,11 @@ namespace
|
||||||
std::ignore = write(STDOUT_FILENO, str, strLen);
|
std::ignore = write(STDOUT_FILENO, str, strLen);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void normalExitHandler(const int signum)
|
void normalExitHandler(const int signum)
|
||||||
{
|
{
|
||||||
#if !(defined Q_OS_WIN && !defined DISABLE_GUI) && !defined Q_OS_HAIKU
|
|
||||||
const char *msgs[] = {"Catching signal: ", sysSigName[signum], "\nExiting cleanly\n"};
|
const char *msgs[] = {"Catching signal: ", sysSigName[signum], "\nExiting cleanly\n"};
|
||||||
std::for_each(std::begin(msgs), std::end(msgs), safePrint);
|
std::for_each(std::begin(msgs), std::end(msgs), safePrint);
|
||||||
#endif // !defined Q_OS_WIN && !defined Q_OS_HAIKU
|
|
||||||
signal(signum, SIG_DFL);
|
signal(signum, SIG_DFL);
|
||||||
QCoreApplication::exit(); // unsafe, but exit anyway
|
QCoreApplication::exit(); // unsafe, but exit anyway
|
||||||
}
|
}
|
||||||
|
@ -101,26 +95,19 @@ namespace
|
||||||
#ifdef STACKTRACE
|
#ifdef STACKTRACE
|
||||||
void abnormalExitHandler(const int signum)
|
void abnormalExitHandler(const int signum)
|
||||||
{
|
{
|
||||||
const char *sigName = sysSigName[signum];
|
|
||||||
|
|
||||||
#if !(defined Q_OS_WIN && !defined DISABLE_GUI) && !defined Q_OS_HAIKU
|
|
||||||
const char msg[] = "\n\n*************************************************************\n"
|
const char msg[] = "\n\n*************************************************************\n"
|
||||||
"Please file a bug report at http://bug.qbittorrent.org and provide the following information:\n\n"
|
"Please file a bug report at http://bug.qbittorrent.org and provide the following information:\n\n"
|
||||||
"qBittorrent version: " QBT_VERSION "\n\n"
|
"qBittorrent version: " QBT_VERSION "\n\n"
|
||||||
"Caught signal: ";
|
"Caught signal: ";
|
||||||
const char *msgs[] = {msg, sigName, "\n"};
|
const char *sigName = sysSigName[signum];
|
||||||
|
const std::string stacktrace = getStacktrace();
|
||||||
|
|
||||||
|
const char *msgs[] = {msg, sigName, "\n```\n", stacktrace.c_str(), "```\n\n"};
|
||||||
std::for_each(std::begin(msgs), std::end(msgs), safePrint);
|
std::for_each(std::begin(msgs), std::end(msgs), safePrint);
|
||||||
|
|
||||||
#if !defined Q_OS_WIN
|
#ifndef DISABLE_GUI
|
||||||
safePrint("```\n");
|
|
||||||
safePrint(getStacktrace().c_str());
|
|
||||||
safePrint("```\n\n");
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined Q_OS_WIN && !defined DISABLE_GUI
|
|
||||||
StacktraceDialog dlg; // unsafe
|
StacktraceDialog dlg; // unsafe
|
||||||
dlg.setText(QString::fromLatin1(sigName), QString::fromStdString(getStacktrace()));
|
dlg.setText(QString::fromLatin1(sigName), QString::fromStdString(stacktrace));
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -134,6 +121,7 @@ void registerSignalHandlers()
|
||||||
{
|
{
|
||||||
signal(SIGINT, normalExitHandler);
|
signal(SIGINT, normalExitHandler);
|
||||||
signal(SIGTERM, normalExitHandler);
|
signal(SIGTERM, normalExitHandler);
|
||||||
|
|
||||||
#ifdef STACKTRACE
|
#ifdef STACKTRACE
|
||||||
signal(SIGABRT, abnormalExitHandler);
|
signal(SIGABRT, abnormalExitHandler);
|
||||||
signal(SIGSEGV, abnormalExitHandler);
|
signal(SIGSEGV, abnormalExitHandler);
|
||||||
|
|
Loading…
Reference in a new issue