From 88b55505400c1458ecdeed44fff366e276493114 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sun, 22 Dec 2013 23:09:25 +0200 Subject: [PATCH] Second attempt at fixing saving settings on shutdown. --- src/headlessloader.h | 5 +++-- src/mainwindow.cpp | 6 +----- src/sessionapplication.cpp | 6 ------ src/sessionapplication.h | 4 ---- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/headlessloader.h b/src/headlessloader.h index c84c0eb72..5a96665f8 100644 --- a/src/headlessloader.h +++ b/src/headlessloader.h @@ -41,6 +41,7 @@ class HeadlessLoader: public QObject { public: HeadlessLoader(const QStringList &torrentCmdLine) { + connect(static_cast(qApp), SIGNAL(aboutToQuit()), this, SLOT(deleteBTSession()), Qt::DirectConnection); Preferences pref; // Enable Web UI pref.setWebUiEnabled(true); @@ -61,11 +62,11 @@ public: } } - ~HeadlessLoader() { +public slots: + void deleteBTSession() { QBtSession::drop(); } -public slots: // Call this function to exit qBittorrent headless loader // and return to prompt (object will be deleted by main) void exit() { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index aa4ded13c..c9b6dfdf0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -110,7 +110,7 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa setWindowTitle(QString("qBittorrent %1").arg(QString::fromUtf8(VERSION))); displaySpeedInTitle = pref.speedInTitleBar(); // Clean exit on log out - connect(static_cast(qApp), SIGNAL(sessionIsShuttingDown()), this, SLOT(deleteBTSession()), Qt::DirectConnection); + connect(static_cast(qApp), SIGNAL(aboutToQuit()), this, SLOT(deleteBTSession()), Qt::DirectConnection); // Setting icons #if defined(Q_WS_X11) if (Preferences().useSystemIconTheme()) @@ -397,10 +397,6 @@ MainWindow::~MainWindow() { delete switchTransferShortcut; delete switchRSSShortcut; IconProvider::drop(); - // Delete QBtSession::instance() object - m_pwr->setActivityState(false); - qDebug("Deleting QBtSession::instance()"); - QBtSession::drop(); qDebug("Exiting GUI destructor..."); } diff --git a/src/sessionapplication.cpp b/src/sessionapplication.cpp index f2a08ad62..9342fd88b 100644 --- a/src/sessionapplication.cpp +++ b/src/sessionapplication.cpp @@ -39,12 +39,6 @@ QtSingleApplication(id, argc, argv) #endif {} -void SessionApplication::commitData(QSessionManager & manager) { - Q_UNUSED(manager); - emit sessionIsShuttingDown(); - manager.release(); -} - bool SessionApplication::notify(QObject* receiver, QEvent* event) { try { return QApplication::notify(receiver, event); diff --git a/src/sessionapplication.h b/src/sessionapplication.h index a7bfbf6fd..1f6232ab3 100644 --- a/src/sessionapplication.h +++ b/src/sessionapplication.h @@ -52,13 +52,9 @@ class SessionApplication : public: SessionApplication(const QString &id, int &argc, char **argv); - void commitData(QSessionManager & manager); protected: virtual bool notify(QObject* receiver, QEvent* event); - - signals: - void sessionIsShuttingDown(); }; #endif // SESSIONAPPLICATION_H