Avoid creating unnecessary event loops

The `exec()` method will create another event loop and transfer
control over there which might introduce unexpected bugs.
This commit is contained in:
Chocobo1 2019-06-03 15:10:19 +08:00
parent 206bb018dd
commit 3748b995ff
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
22 changed files with 509 additions and 476 deletions

View file

@ -578,12 +578,14 @@ void MainWindow::addToolbarContextMenu()
void MainWindow::manageCookies()
{
CookiesDialog(this).exec();
auto *cookieDialog = new CookiesDialog(this);
cookieDialog->setAttribute(Qt::WA_DeleteOnClose);
cookieDialog->open();
}
void MainWindow::toolbarMenuRequested(QPoint point)
void MainWindow::toolbarMenuRequested(const QPoint &point)
{
m_toolbarMenu->exec(m_ui->toolBar->mapToGlobal(point));
m_toolbarMenu->popup(m_ui->toolBar->mapToGlobal(point));
}
void MainWindow::toolbarIconsOnly()
@ -688,7 +690,9 @@ void MainWindow::showFilterContextMenu(const QPoint &)
const Preferences *pref = Preferences::instance();
QMenu *menu = m_searchFilter->createStandardContextMenu();
menu->setAttribute(Qt::WA_DeleteOnClose);
menu->addSeparator();
QAction *useRegexAct = new QAction(tr("Use regular expressions"), menu);
useRegexAct->setCheckable(true);
useRegexAct->setChecked(pref->getRegexAsFilteringPatternForTransferList());
@ -697,7 +701,7 @@ void MainWindow::showFilterContextMenu(const QPoint &)
connect(useRegexAct, &QAction::toggled, pref, &Preferences::setRegexAsFilteringPatternForTransferList);
connect(useRegexAct, &QAction::toggled, this, [this]() { m_transferListWidget->applyNameFilter(m_searchFilter->text()); });
menu->exec(QCursor::pos());
menu->popup(QCursor::pos());
}
void MainWindow::displaySearchTab(bool enable)