From 0a3406ea80e0abbd58b6af217dfd370e56351ec6 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Tue, 21 Apr 2015 12:58:21 +0300 Subject: [PATCH] Fix aboutToQuit signal is not emitted on Windows. In some cases QApplication::aboutToQuit() and QApplication::commitDataRequest() signals not emitted on Windows. This happened when qBittorrent is started with both "Show minimized" and "Minimize to system tray" enabled. --- src/gui/mainwindow.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 60d2857e6..65c4ac622 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -316,6 +316,20 @@ MainWindow::MainWindow(QWidget *parent) activateWindow(); raise(); } + else { + create(); + } + } + else { + // Make sure the Window is visible if we don't have a tray icon + if (pref->startMinimized()) { + showMinimized(); + } + else { + show(); + activateWindow(); + raise(); + } } properties->readSettings(); @@ -351,18 +365,6 @@ MainWindow::MainWindow(QWidget *parent) #ifdef Q_OS_MAC qt_mac_set_dock_menu(getTrayIconMenu()); #endif - - // Make sure the Window is visible if we don't have a tray icon - if (!systrayIcon) { - if (pref->startMinimized()) { - showMinimized(); - } - else { - show(); - activateWindow(); - raise(); - } - } } MainWindow::~MainWindow() @@ -882,6 +884,7 @@ void MainWindow::closeEvent(QCloseEvent *e) e->accept(); return; } + if (pref->confirmOnExit() && QBtSession::instance()->hasActiveTorrents()) { if (e->spontaneous() || force_exit) { if (!isVisible()) @@ -905,12 +908,11 @@ void MainWindow::closeEvent(QCloseEvent *e) Preferences::instance()->setConfirmOnExit(false); } } + hide(); + // Hide tray icon if (systrayIcon) - // Hide tray icon systrayIcon->hide(); - // Save window size, columns size - writeSettings(); // Accept exit e->accept(); qApp->exit();