From e96c1bf0da93d3448d09d2364a910e4d784d5723 Mon Sep 17 00:00:00 2001 From: Jarek Kobus <jaroslaw.kobus@qt.io> Date: Fri, 6 Apr 2018 16:44:09 +0200 Subject: [PATCH] Fix possible crash inside connection to the lambda Pass "this" context object to the connect(). Otherwise when "this" instance gets deleted and the sender still exists, the lambda expression is still invoked for the deleted object. Change-Id: I0a38489fac302a85abc80928c6244383ff1870ff Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> --- src/assistant/assistant/bookmarkmanager.cpp | 2 +- src/assistant/assistant/bookmarkmanagerwidget.cpp | 2 +- src/assistant/assistant/mainwindow.cpp | 4 ++-- src/assistant/help/qhelpcontentwidget.cpp | 2 +- src/assistant/help/qhelpindexwidget.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/assistant/assistant/bookmarkmanager.cpp b/src/assistant/assistant/bookmarkmanager.cpp index fe1b04067..59b9db6aa 100644 --- a/src/assistant/assistant/bookmarkmanager.cpp +++ b/src/assistant/assistant/bookmarkmanager.cpp @@ -183,7 +183,7 @@ BookmarkManager::BookmarkManager() bookmarkWidget->ui.stackedWidget->addWidget(bookmarkTreeView); connect(bookmarkTreeView, &QAbstractItemView::activated, - [this](const QModelIndex &index) { setSourceFromIndex(index, false); }); + this, [this](const QModelIndex &index) { setSourceFromIndex(index, false); }); connect(bookmarkTreeView, &QWidget::customContextMenuRequested, this, &BookmarkManager::customContextMenuRequested); connect(bookmarkTreeView, &BookmarkTreeView::editingDone, diff --git a/src/assistant/assistant/bookmarkmanagerwidget.cpp b/src/assistant/assistant/bookmarkmanagerwidget.cpp index 9d7b9cc57..76d857963 100644 --- a/src/assistant/assistant/bookmarkmanagerwidget.cpp +++ b/src/assistant/assistant/bookmarkmanagerwidget.cpp @@ -62,7 +62,7 @@ BookmarkManagerWidget::BookmarkManagerWidget(BookmarkModel *sourceModel, this, &BookmarkManagerWidget::customContextMenuRequested); connect(ui.remove, &QAbstractButton::clicked, - [this]() { removeItem(); }); + this, [this]() { removeItem(); }); connect(ui.lineEdit, &QLineEdit::textChanged, this, &BookmarkManagerWidget::textChanged); QShortcut *shortcut = new QShortcut(QKeySequence::Find, ui.lineEdit); diff --git a/src/assistant/assistant/mainwindow.cpp b/src/assistant/assistant/mainwindow.cpp index 2ceb86d3b..d81cc45fd 100644 --- a/src/assistant/assistant/mainwindow.cpp +++ b/src/assistant/assistant/mainwindow.cpp @@ -163,7 +163,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) connect(bookMarkManager, &BookmarkManager::setSource, m_centralWidget, &CentralWidget::setSource); connect(bookMarkManager, &BookmarkManager::setSourceInNewTab, - [openPagesManager](const QUrl &url){ openPagesManager->createPage(url); }); + openPagesManager, [openPagesManager](const QUrl &url){ openPagesManager->createPage(url); }); QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine(); connect(searchEngine, &QHelpSearchEngine::indexingStarted, @@ -681,7 +681,7 @@ void MainWindow::setupActions() connect(m_centralWidget, &CentralWidget::backwardAvailable, globalActions, &GlobalActions::updateActions); connect(m_centralWidget, &CentralWidget::highlighted, - [this](const QString &link) { statusBar()->showMessage(link);} ); + this, [this](const QString &link) { statusBar()->showMessage(link);} ); // index window connect(m_indexWindow, &IndexWindow::linkActivated, diff --git a/src/assistant/help/qhelpcontentwidget.cpp b/src/assistant/help/qhelpcontentwidget.cpp index 5d57f1d04..ee7f974aa 100644 --- a/src/assistant/help/qhelpcontentwidget.cpp +++ b/src/assistant/help/qhelpcontentwidget.cpp @@ -349,7 +349,7 @@ QHelpContentModel::QHelpContentModel(QHelpEnginePrivate *helpEngine) connect(d->qhelpContentProvider, &QHelpContentProvider::finishedSuccessFully, this, &QHelpContentModel::insertContents, Qt::QueuedConnection); connect(helpEngine->q, &QHelpEngineCore::readersAboutToBeInvalidated, - [this]() { invalidateContents(); }); + this, [this]() { invalidateContents(); }); } /*! diff --git a/src/assistant/help/qhelpindexwidget.cpp b/src/assistant/help/qhelpindexwidget.cpp index abd3b40e8..fb65aceb5 100644 --- a/src/assistant/help/qhelpindexwidget.cpp +++ b/src/assistant/help/qhelpindexwidget.cpp @@ -223,7 +223,7 @@ QHelpIndexModel::QHelpIndexModel(QHelpEnginePrivate *helpEngine) connect(d->indexProvider, &QThread::finished, this, &QHelpIndexModel::insertIndices); connect(helpEngine->q, &QHelpEngineCore::readersAboutToBeInvalidated, - [this]() { invalidateIndex(); }); + this, [this]() { invalidateIndex(); }); } QHelpIndexModel::~QHelpIndexModel() -- GitLab