forked from qt-creator/qt-creator
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:
@@ -55,6 +55,7 @@
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QDebug>
|
||||
#include <QPointer>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user