mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 12:34:19 +00:00
Catch SIGTERM to exit cleanly (e.g. computer shutdown)
This commit is contained in:
parent
dfb2046f82
commit
6a3dddd0cc
@ -18,6 +18,7 @@
|
|||||||
- BUGFIX: Fixed spacing problem in toolbar when toggling its visibility
|
- BUGFIX: Fixed spacing problem in toolbar when toggling its visibility
|
||||||
- BUGFIX: Fixed some compilation and Qt4 warnings
|
- BUGFIX: Fixed some compilation and Qt4 warnings
|
||||||
- BUGFIX: Do not use an addition dialog for torrents from folder scanning
|
- BUGFIX: Do not use an addition dialog for torrents from folder scanning
|
||||||
|
- BUGFIX: Catch SIGTERM to exit cleanly (e.g. computer shutdown)
|
||||||
|
|
||||||
* Sun Nov 9 2008 - Christophe Dumez <chris@qbittorrent.org> - v1.2.1
|
* Sun Nov 9 2008 - Christophe Dumez <chris@qbittorrent.org> - v1.2.1
|
||||||
- BUGFIX: Fixed possible crash when deleting a torrent permanently
|
- BUGFIX: Fixed possible crash when deleting a torrent permanently
|
||||||
|
@ -244,6 +244,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
|
|||||||
// Destructor
|
// Destructor
|
||||||
GUI::~GUI() {
|
GUI::~GUI() {
|
||||||
qDebug("GUI destruction");
|
qDebug("GUI destruction");
|
||||||
|
hide();
|
||||||
delete dlSpeedLbl;
|
delete dlSpeedLbl;
|
||||||
delete upSpeedLbl;
|
delete upSpeedLbl;
|
||||||
delete ratioLbl;
|
delete ratioLbl;
|
||||||
|
30
src/main.cpp
30
src/main.cpp
@ -43,12 +43,23 @@
|
|||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
#include <QMacStyle>
|
#include <QMacStyle>
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef Q_WS_WIN
|
||||||
|
#include <signal.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "GUI.h"
|
#include "GUI.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "ico.h"
|
#include "ico.h"
|
||||||
|
|
||||||
|
QApplication *app;
|
||||||
|
|
||||||
|
#ifndef Q_WS_WIN
|
||||||
|
void sigtermHandler(int) {
|
||||||
|
qDebug("Catching SIGTERM, exiting cleanly");
|
||||||
|
app->exit();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void useStyle(QApplication *app, int style){
|
void useStyle(QApplication *app, int style){
|
||||||
switch(style) {
|
switch(style) {
|
||||||
@ -144,9 +155,9 @@ int main(int argc, char *argv[]){
|
|||||||
#ifndef QT_4_4
|
#ifndef QT_4_4
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
QApplication app(argc, argv);
|
app = new QApplication(argc, argv);
|
||||||
useStyle(&app, settings.value("Preferences/General/Style", 0).toInt());
|
useStyle(app, settings.value("Preferences/General/Style", 0).toInt());
|
||||||
app.setStyleSheet("QStatusBar::item { border-width: 0; }");
|
app->setStyleSheet("QStatusBar::item { border-width: 0; }");
|
||||||
QSplashScreen *splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/Icons/splash.png")));
|
QSplashScreen *splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/Icons/splash.png")));
|
||||||
splash->show();
|
splash->show();
|
||||||
// Open options file to read locale
|
// Open options file to read locale
|
||||||
@ -161,17 +172,20 @@ int main(int argc, char *argv[]){
|
|||||||
}else{
|
}else{
|
||||||
qDebug("%s locale unrecognized, using default (en_GB).", (const char*)locale.toUtf8());
|
qDebug("%s locale unrecognized, using default (en_GB).", (const char*)locale.toUtf8());
|
||||||
}
|
}
|
||||||
app.installTranslator(&translator);
|
app->installTranslator(&translator);
|
||||||
app.setApplicationName(QString::fromUtf8("qBittorrent"));
|
app->setApplicationName(QString::fromUtf8("qBittorrent"));
|
||||||
app.setQuitOnLastWindowClosed(false);
|
app->setQuitOnLastWindowClosed(false);
|
||||||
// Read torrents given on command line
|
// Read torrents given on command line
|
||||||
QStringList torrentCmdLine = app.arguments();
|
QStringList torrentCmdLine = app->arguments();
|
||||||
// Remove first argument (program name)
|
// Remove first argument (program name)
|
||||||
torrentCmdLine.removeFirst();
|
torrentCmdLine.removeFirst();
|
||||||
GUI window(0, torrentCmdLine);
|
GUI window(0, torrentCmdLine);
|
||||||
splash->finish(&window);
|
splash->finish(&window);
|
||||||
delete splash;
|
delete splash;
|
||||||
return app.exec();
|
#ifndef Q_WS_WIN
|
||||||
|
signal(SIGTERM, sigtermHandler);
|
||||||
|
#endif
|
||||||
|
return app->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user