Skip to content

Commit

Permalink
Prevent tray menu from being accessed after destruction
Browse files Browse the repository at this point in the history
PR #17400.
  • Loading branch information
glassez authored Jul 21, 2022
1 parent 71e53a4 commit 5b269a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <QProcess>

#ifndef DISABLE_GUI
#include <QMenu>
#include <QMessageBox>
#include <QPixmapCache>
#ifdef Q_OS_WIN
Expand Down Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ MainWindow::MainWindow(IGUIApplication *app, QWidget *parent)

MainWindow::~MainWindow()
{
app()->desktopIntegration()->setMenu(nullptr);
delete m_ui;
}

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 5b269a7

Please sign in to comment.