diff options
-rw-r--r-- | src/plugins/cpptools/cppprojectupdater.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/cpptools/cppprojectupdater.cpp b/src/plugins/cpptools/cppprojectupdater.cpp index f34628af51..61d9443c98 100644 --- a/src/plugins/cpptools/cppprojectupdater.cpp +++ b/src/plugins/cpptools/cppprojectupdater.cpp @@ -93,11 +93,16 @@ void CppProjectUpdater::update(const ProjectUpdateInfo &projectUpdateInfo, // extra compilers for (QPointer<ExtraCompiler> compiler : qAsConst(m_extraCompilers)) { if (compiler->isDirty()) { - auto watcher = new QFutureWatcher<void>; + QPointer<QFutureWatcher<void>> watcher = new QFutureWatcher<void>; // queued connection to delay after the extra compiler updated its result contents, // which is also done in the main thread when compiler->run() finished connect(watcher, &QFutureWatcherBase::finished, this, [this, watcher] { + // In very unlikely case the CppProjectUpdater::cancel() could have been + // invoked after posting the finished() signal and before this handler + // gets called. In this case the watcher is already deleted. + if (!watcher) + return; m_projectUpdateFutureInterface->setProgressValue( m_projectUpdateFutureInterface->progressValue() + 1); m_extraCompilersFutureWatchers.remove(watcher); |