CMake: fix crash on project close during active file system scanning

TreeScanner uses callbacks that can refers to the destroyed objectes
when project closing.

Found scenario:
1. Open big CMake-based project (CLang/LLVM good choose).
2. Until file system scanning finished switch to another session.

Change-Id: Ia0f55f38aea6a9d07ca81aee6c9e9c5662d74f3a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Alexander Drozdov
2017-02-14 16:34:22 +10:00
committed by Tobias Hunger
parent 336adaa604
commit bc46ba11ee
3 changed files with 14 additions and 0 deletions

View File

@@ -128,6 +128,11 @@ CMakeProject::CMakeProject(CMakeManager *manager, const FileName &fileName)
CMakeProject::~CMakeProject()
{
if (!m_treeScanner.isFinished()) {
auto future = m_treeScanner.future();
future.cancel();
future.waitForFinished();
}
setRootProjectNode(nullptr);
m_codeModelFuture.cancel();
qDeleteAll(m_extraCompilers);