mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-21 08:09:35 +08:00
Use proper method for deferred calls
This commit is contained in:
parent
a59a6ce8e4
commit
3f762a416d
@ -47,6 +47,7 @@
|
||||
#include <QByteArray>
|
||||
#include <QDebug>
|
||||
#include <QLibraryInfo>
|
||||
#include <QMetaObject>
|
||||
#include <QProcess>
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
@ -770,7 +771,7 @@ void Application::shutdownCleanup(QSessionManager &manager)
|
||||
// According to the qt docs we shouldn't call quit() inside a slot.
|
||||
// aboutToQuit() is never emitted if the user hits "Cancel" in
|
||||
// the above dialog.
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
QMetaObject::invokeMethod(qApp, &QCoreApplication::quit, Qt::QueuedConnection);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "searchhandler.h"
|
||||
|
||||
#include <QMetaObject>
|
||||
#include <QProcess>
|
||||
#include <QTimer>
|
||||
#include <QVector>
|
||||
@ -87,7 +88,8 @@ SearchHandler::SearchHandler(const QString &pattern, const QString &category, co
|
||||
m_searchTimeout->start(180000); // 3 min
|
||||
|
||||
// deferred start allows clients to handle starting-related signals
|
||||
QTimer::singleShot(0, this, [this]() { m_searchProcess->start(QIODevice::ReadOnly); });
|
||||
QMetaObject::invokeMethod(this, [this]() { m_searchProcess->start(QIODevice::ReadOnly); }
|
||||
, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
bool SearchHandler::isActive() const
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QKeyEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaObject>
|
||||
#include <QMimeData>
|
||||
#include <QProcess>
|
||||
#include <QPushButton>
|
||||
@ -348,8 +349,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
on_actionWarningMessages_triggered(m_ui->actionWarningMessages->isChecked());
|
||||
on_actionCriticalMessages_triggered(m_ui->actionCriticalMessages->isChecked());
|
||||
if (m_ui->actionSearchWidget->isChecked())
|
||||
QTimer::singleShot(0, this, &MainWindow::on_actionSearchWidget_triggered);
|
||||
|
||||
QMetaObject::invokeMethod(this, &MainWindow::on_actionSearchWidget_triggered, Qt::QueuedConnection);
|
||||
// Auto shutdown actions
|
||||
auto *autoShutdownGroup = new QActionGroup(this);
|
||||
autoShutdownGroup->setExclusive(true);
|
||||
@ -1195,7 +1195,7 @@ void MainWindow::closeEvent(QCloseEvent *e)
|
||||
if (!m_forceExit && m_systrayIcon && goToSystrayOnExit && !this->isHidden())
|
||||
{
|
||||
e->ignore();
|
||||
QTimer::singleShot(0, this, &QWidget::hide);
|
||||
QMetaObject::invokeMethod(this, &QWidget::hide, Qt::QueuedConnection);
|
||||
if (!pref->closeToTrayNotified())
|
||||
{
|
||||
showNotificationBalloon(tr("qBittorrent is closed to tray"), tr("This behavior can be changed in the settings. You won't be reminded again."));
|
||||
@ -1292,7 +1292,7 @@ bool MainWindow::event(QEvent *e)
|
||||
{
|
||||
qDebug("Minimize to Tray enabled, hiding!");
|
||||
e->ignore();
|
||||
QTimer::singleShot(0, this, &QWidget::hide);
|
||||
QMetaObject::invokeMethod(this, &QWidget::hide, Qt::QueuedConnection);
|
||||
if (!pref->minimizeToTrayNotified())
|
||||
{
|
||||
showNotificationBalloon(tr("qBittorrent is minimized to tray"), tr("This behavior can be changed in the settings. You won't be reminded again."));
|
||||
|
Loading…
Reference in New Issue
Block a user