From 06b653879fb5c73889d9db477f9e905a00495e87 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 4 Nov 2020 13:50:31 +0100 Subject: [PATCH] ModelEditor: Guard project pointer in queued connection We cannot assume that the project pointer is still valid when event loop execution continues. Fixes: QTCREATORBUG-24893 Change-Id: I9a3f7a3fae45a04054da6f81c1c8e3181f658de4 Reviewed-by: hjk --- src/plugins/modeleditor/modelindexer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/modeleditor/modelindexer.cpp b/src/plugins/modeleditor/modelindexer.cpp index 5186a269f33..45136440edf 100644 --- a/src/plugins/modeleditor/modelindexer.cpp +++ b/src/plugins/modeleditor/modelindexer.cpp @@ -55,6 +55,7 @@ #include #include +#include namespace ModelEditor { namespace Internal { @@ -373,7 +374,7 @@ void ModelIndexer::onProjectAdded(ProjectExplorer::Project *project) connect(project, &ProjectExplorer::Project::fileListChanged, this, - [=]() { this->onProjectFileListChanged(project); }, + [this, p = QPointer(project)] { if (p) onProjectFileListChanged(p.data()); }, Qt::QueuedConnection); scanProject(project); }