TreeScanner: Pass a copy of filter and factory into async call

Otherwise, m_filter and m_factory may be used from 2 threads
at the same time, what is not thread safe (setFilter() /
setTypeFactory() from caller thread, and copy of m_filter and m_factory
inside async call body).

Change-Id: Ic322870f9c27de10c5c51082cfbb85c729326993
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2022-11-02 09:33:10 +01:00
parent 648fe3160f
commit 2c04c644d0

View File

@@ -45,8 +45,9 @@ bool TreeScanner::asyncScanForFiles(const Utils::FilePath &directory)
if (!m_futureWatcher.isFinished()) if (!m_futureWatcher.isFinished())
return false; return false;
m_scanFuture = Utils::runAsync([this, directory](FutureInterface &fi) { m_scanFuture = Utils::runAsync(
TreeScanner::scanForFiles(fi, directory, m_filter, m_factory); [directory, filter = m_filter, factory = m_factory] (FutureInterface &fi) {
TreeScanner::scanForFiles(fi, directory, filter, factory);
}); });
m_futureWatcher.setFuture(m_scanFuture); m_futureWatcher.setFuture(m_scanFuture);