Browse Source

Prevent tray menu from being accessed after destruction

PR #17400.
adaptive-webui-19844
Vladimir Golovnev 2 years ago committed by GitHub
parent
commit
5b269a782a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/app/application.cpp
  2. 6
      src/gui/mainwindow.cpp

9
src/app/application.cpp

@ -50,6 +50,7 @@ @@ -50,6 +50,7 @@
#include <QProcess>
#ifndef DISABLE_GUI
#include <QMenu>
#include <QMessageBox>
#include <QPixmapCache>
#ifdef Q_OS_WIN
@ -973,6 +974,14 @@ void Application::cleanup() @@ -973,6 +974,14 @@ void Application::cleanup()
LogMsg(tr("qBittorrent termination initiated"));
#ifndef DISABLE_GUI
if (m_desktopIntegration)
{
m_desktopIntegration->disconnect();
m_desktopIntegration->setToolTip(tr("qBittorrent is shutting down..."));
if (m_desktopIntegration->menu())
m_desktopIntegration->menu()->setEnabled(false);
}
if (m_window)
{
// Hide the window and don't leave it on screen as

6
src/gui/mainwindow.cpp

@ -481,6 +481,7 @@ MainWindow::MainWindow(IGUIApplication *app, QWidget *parent) @@ -481,6 +481,7 @@ MainWindow::MainWindow(IGUIApplication *app, QWidget *parent)
MainWindow::~MainWindow()
{
app()->desktopIntegration()->setMenu(nullptr);
delete m_ui;
}
@ -1171,11 +1172,6 @@ void MainWindow::closeEvent(QCloseEvent *e) @@ -1171,11 +1172,6 @@ void MainWindow::closeEvent(QCloseEvent *e)
}
}
// Disable some UI to prevent user interactions
app()->desktopIntegration()->disconnect();
app()->desktopIntegration()->setToolTip(tr("qBittorrent is shutting down..."));
app()->desktopIntegration()->menu()->setEnabled(false);
// Accept exit
e->accept();
qApp->exit();

Loading…
Cancel
Save