mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 01:03:08 -07:00
BUGFIX: qBittorrent now prints backtrace in terminal when segfaulting
This commit is contained in:
parent
573f00c66c
commit
68e30de763
5 changed files with 112 additions and 4 deletions
16
src/main.cpp
16
src/main.cpp
|
@ -45,6 +45,8 @@
|
|||
#endif
|
||||
#ifndef Q_WS_WIN
|
||||
#include <signal.h>
|
||||
#include <execinfo.h>
|
||||
#include "stacktrace.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -59,6 +61,13 @@ QApplication *app;
|
|||
qDebug("Catching SIGTERM, exiting cleanly");
|
||||
app->exit();
|
||||
}
|
||||
void sigsegvHandler(int) {
|
||||
std::cerr << "\n\n*************************************************************\n";
|
||||
std::cerr << "Catching SIGSEGV, please report a bug at http://bug.qbittorrent.org\nand provide the following backtrace:\n";
|
||||
print_stacktrace();
|
||||
std::raise(SIGINT);
|
||||
std::abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
void useStyle(QApplication *app, int style){
|
||||
|
@ -177,6 +186,10 @@ int main(int argc, char *argv[]){
|
|||
app->installTranslator(&translator);
|
||||
app->setApplicationName(QString::fromUtf8("qBittorrent"));
|
||||
app->setQuitOnLastWindowClosed(false);
|
||||
#ifndef Q_WS_WIN
|
||||
signal(SIGTERM, sigtermHandler);
|
||||
signal(SIGSEGV, sigsegvHandler);
|
||||
#endif
|
||||
// Read torrents given on command line
|
||||
QStringList torrentCmdLine = app->arguments();
|
||||
// Remove first argument (program name)
|
||||
|
@ -184,9 +197,6 @@ int main(int argc, char *argv[]){
|
|||
GUI *window = new GUI(0, torrentCmdLine);
|
||||
splash->finish(window);
|
||||
delete splash;
|
||||
#ifndef Q_WS_WIN
|
||||
signal(SIGTERM, sigtermHandler);
|
||||
#endif
|
||||
int ret = app->exec();
|
||||
delete window;
|
||||
delete app;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue