mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 14:04:23 +00:00
- Fixing indentation
- Stop catching SIGINT and SIGTERM once the application has exiting
This commit is contained in:
parent
78ba99778a
commit
99459dc55d
1750
src/bittorrent.cpp
1750
src/bittorrent.cpp
File diff suppressed because it is too large
Load Diff
@ -35,10 +35,10 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#ifdef DISABLE_GUI
|
#ifdef DISABLE_GUI
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#else
|
#else
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#endif
|
#endif
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
|
50
src/main.cpp
50
src/main.cpp
@ -33,23 +33,23 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QSplashScreen>
|
#include <QSplashScreen>
|
||||||
#include <QPlastiqueStyle>
|
#include <QPlastiqueStyle>
|
||||||
#include "qgnomelook.h"
|
#include "qgnomelook.h"
|
||||||
#include <QMotifStyle>
|
#include <QMotifStyle>
|
||||||
#include <QCDEStyle>
|
#include <QCDEStyle>
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
#include <QWindowsXPStyle>
|
#include <QWindowsXPStyle>
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
#include <QMacStyle>
|
#include <QMacStyle>
|
||||||
#endif
|
#endif
|
||||||
#include "GUI.h"
|
#include "GUI.h"
|
||||||
#include "ico.h"
|
#include "ico.h"
|
||||||
#else
|
#else
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include "headlessloader.h"
|
#include "headlessloader.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@ -67,12 +67,17 @@
|
|||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
|
|
||||||
#ifdef DISABLE_GUI
|
#ifdef DISABLE_GUI
|
||||||
QCoreApplication *app;
|
QCoreApplication *app;
|
||||||
#else
|
#else
|
||||||
QApplication *app;
|
QApplication *app;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_WS_WIN
|
||||||
|
void sigintHandler(int) {
|
||||||
|
qDebug("Catching SIGINT, exiting cleanly");
|
||||||
|
app->exit();
|
||||||
|
}
|
||||||
|
|
||||||
void sigtermHandler(int) {
|
void sigtermHandler(int) {
|
||||||
qDebug("Catching SIGTERM, exiting cleanly");
|
qDebug("Catching SIGTERM, exiting cleanly");
|
||||||
app->exit();
|
app->exit();
|
||||||
@ -246,7 +251,7 @@ int main(int argc, char *argv[]){
|
|||||||
#ifndef Q_WS_WIN
|
#ifndef Q_WS_WIN
|
||||||
signal(SIGABRT, sigabrtHandler);
|
signal(SIGABRT, sigabrtHandler);
|
||||||
signal(SIGTERM, sigtermHandler);
|
signal(SIGTERM, sigtermHandler);
|
||||||
signal(SIGINT, sigtermHandler);
|
signal(SIGINT, sigintHandler);
|
||||||
signal(SIGSEGV, sigsegvHandler);
|
signal(SIGSEGV, sigsegvHandler);
|
||||||
#endif
|
#endif
|
||||||
// Read torrents given on command line
|
// Read torrents given on command line
|
||||||
@ -264,6 +269,13 @@ int main(int argc, char *argv[]){
|
|||||||
HeadlessLoader *loader = new HeadlessLoader(torrentCmdLine);
|
HeadlessLoader *loader = new HeadlessLoader(torrentCmdLine);
|
||||||
#endif
|
#endif
|
||||||
int ret = app->exec();
|
int ret = app->exec();
|
||||||
|
|
||||||
|
#ifndef Q_WS_WIN
|
||||||
|
// Application has exited, stop catching SIGINT and SIGTERM
|
||||||
|
signal(SIGINT, 0);
|
||||||
|
signal(SIGTERM, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
delete window;
|
delete window;
|
||||||
qDebug("GUI was deleted!");
|
qDebug("GUI was deleted!");
|
||||||
|
86
src/misc.h
86
src/misc.h
@ -47,9 +47,9 @@
|
|||||||
#include <boost/date_time/posix_time/conversion.hpp>
|
#include <boost/date_time/posix_time/conversion.hpp>
|
||||||
|
|
||||||
#ifdef DISABLE_GUI
|
#ifdef DISABLE_GUI
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#else
|
#else
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
@ -183,68 +183,68 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
static QString getFullPath(const FSRef &ref)
|
static QString getFullPath(const FSRef &ref)
|
||||||
{
|
{
|
||||||
QByteArray ba(2048, 0);
|
QByteArray ba(2048, 0);
|
||||||
if (FSRefMakePath(&ref, reinterpret_cast<UInt8 *>(ba.data()), ba.size()) == noErr)
|
if (FSRefMakePath(&ref, reinterpret_cast<UInt8 *>(ba.data()), ba.size()) == noErr)
|
||||||
return QString::fromUtf8(ba).normalized(QString::NormalizationForm_C);
|
return QString::fromUtf8(ba).normalized(QString::NormalizationForm_C);
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QString QDesktopServicesDataLocation() {
|
static QString QDesktopServicesDataLocation() {
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
#if defined Q_WS_WINCE
|
#if defined Q_WS_WINCE
|
||||||
if (SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE))
|
if (SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE))
|
||||||
#else
|
#else
|
||||||
if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
|
if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
|
||||||
#endif
|
#endif
|
||||||
result = QString::fromWCharArray(path);
|
result = QString::fromWCharArray(path);
|
||||||
if (!QCoreApplication::applicationName().isEmpty())
|
if (!QCoreApplication::applicationName().isEmpty())
|
||||||
result = result + QLatin1String("\\") + qApp->applicationName();
|
result = result + QLatin1String("\\") + qApp->applicationName();
|
||||||
#else
|
#else
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
|
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
|
||||||
FSRef ref;
|
FSRef ref;
|
||||||
OSErr err = FSFindFolder(kUserDomain, kApplicationSupportFolderType, false, &ref);
|
OSErr err = FSFindFolder(kUserDomain, kApplicationSupportFolderType, false, &ref);
|
||||||
if (err)
|
if (err)
|
||||||
return QString();
|
return QString();
|
||||||
QString path = getFullPath(ref);
|
QString path = getFullPath(ref);
|
||||||
path += QLatin1Char('/') + qApp->applicationName();
|
path += QLatin1Char('/') + qApp->applicationName();
|
||||||
return path;
|
return path;
|
||||||
#else
|
#else
|
||||||
QString xdgDataHome = QLatin1String(qgetenv("XDG_DATA_HOME"));
|
QString xdgDataHome = QLatin1String(qgetenv("XDG_DATA_HOME"));
|
||||||
if (xdgDataHome.isEmpty())
|
if (xdgDataHome.isEmpty())
|
||||||
xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");
|
xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");
|
||||||
xdgDataHome += QLatin1String("/data/")
|
xdgDataHome += QLatin1String("/data/")
|
||||||
+ qApp->applicationName();
|
+ qApp->applicationName();
|
||||||
return xdgDataHome;
|
return xdgDataHome;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString QDesktopServicesCacheLocation() {
|
static QString QDesktopServicesCacheLocation() {
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
return QDesktopServicesDataLocation() + QLatin1String("\\cache");
|
return QDesktopServicesDataLocation() + QLatin1String("\\cache");
|
||||||
#else
|
#else
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
|
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
|
||||||
FSRef ref;
|
FSRef ref;
|
||||||
OSErr err = FSFindFolder(kUserDomain, kCachedDataFolderType, false, &ref);
|
OSErr err = FSFindFolder(kUserDomain, kCachedDataFolderType, false, &ref);
|
||||||
if (err)
|
if (err)
|
||||||
return QString();
|
return QString();
|
||||||
QString path = getFullPath(ref);
|
QString path = getFullPath(ref);
|
||||||
path += QLatin1Char('/') + qApp->applicationName();
|
path += QLatin1Char('/') + qApp->applicationName();
|
||||||
return path;
|
return path;
|
||||||
#else
|
#else
|
||||||
QString xdgCacheHome = QLatin1String(qgetenv("XDG_CACHE_HOME"));
|
QString xdgCacheHome = QLatin1String(qgetenv("XDG_CACHE_HOME"));
|
||||||
if (xdgCacheHome.isEmpty())
|
if (xdgCacheHome.isEmpty())
|
||||||
xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
|
xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
|
||||||
xdgCacheHome += QLatin1Char('/') + QCoreApplication::applicationName();
|
xdgCacheHome += QLatin1Char('/') + QCoreApplication::applicationName();
|
||||||
return xdgCacheHome;
|
return xdgCacheHome;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString searchEngineLocation() {
|
static QString searchEngineLocation() {
|
||||||
QString location = QDir::cleanPath(QDesktopServicesDataLocation()
|
QString location = QDir::cleanPath(QDesktopServicesDataLocation()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user