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 <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2020-11-04 13:50:31 +01:00
parent 6a1f51b195
commit 06b653879f

View File

@@ -55,6 +55,7 @@
#include <QLoggingCategory> #include <QLoggingCategory>
#include <QDebug> #include <QDebug>
#include <QPointer>
namespace ModelEditor { namespace ModelEditor {
namespace Internal { namespace Internal {
@@ -373,7 +374,7 @@ void ModelIndexer::onProjectAdded(ProjectExplorer::Project *project)
connect(project, connect(project,
&ProjectExplorer::Project::fileListChanged, &ProjectExplorer::Project::fileListChanged,
this, this,
[=]() { this->onProjectFileListChanged(project); }, [this, p = QPointer(project)] { if (p) onProjectFileListChanged(p.data()); },
Qt::QueuedConnection); Qt::QueuedConnection);
scanProject(project); scanProject(project);
} }