From 584f0476eca8676abc652d8e907b5e10c08da787 Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed Date: Thu, 24 Jun 2021 17:56:13 +0200 Subject: [PATCH] qmljstools::LocatorData: improve safety * check that we create LocatorData in the same thread as the ModelManagerInterface * pass this as connect context, to ensure signal disconnect Change-Id: I5e51af90c521fd8c83a6cfe2d105832f5a02a04f Reviewed-by: Jarek Kobus --- src/plugins/qmljstools/qmljslocatordata.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/qmljstools/qmljslocatordata.cpp b/src/plugins/qmljstools/qmljslocatordata.cpp index 39ef4f4de5a..92611a99a64 100644 --- a/src/plugins/qmljstools/qmljslocatordata.cpp +++ b/src/plugins/qmljstools/qmljslocatordata.cpp @@ -43,6 +43,7 @@ using namespace QmlJS::AST; LocatorData::LocatorData() { ModelManagerInterface *manager = ModelManagerInterface::instance(); + Q_ASSERT(thread() == manager->thread()); // we do not protect accesses below // Force the updating of source file when updating a project (they could be cached, in such // case LocatorData::onDocumentUpdated will not be called. @@ -61,8 +62,10 @@ LocatorData::LocatorData() ProjectExplorer::SessionManager *session = ProjectExplorer::SessionManager::instance(); if (session) - connect(session, &ProjectExplorer::SessionManager::projectRemoved, - [this] (ProjectExplorer::Project*) { m_entries.clear(); }); + connect(session, + &ProjectExplorer::SessionManager::projectRemoved, + this, + [this](ProjectExplorer::Project *) { m_entries.clear(); }); } LocatorData::~LocatorData() = default;