diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index 56cee3bc51e..d529ee8dccb 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -375,21 +375,27 @@ void TestCodeParser::scanForTests(const QSet &filePaths, if (limit == 0) limit = std::max(QThread::idealThreadCount() / 4, 1); qCDebug(LOG) << "Using" << limit << "threads for scan."; - QList tasks{parallelLimit(limit)}; - for (const FilePath &file : filteredFiles) { - const auto onSetup = [this, codeParsers, file](Async &async) { - async.setConcurrentCallData(parseFileForTests, codeParsers, file); - async.setPriority(QThread::LowestPriority); - async.setFutureSynchronizer(&m_futureSynchronizer); - }; - const auto onDone = [this](const Async &async) { - const QList results = async.results(); - for (const TestParseResultPtr &result : results) - emit testParseResultReady(result); - }; - tasks.append(AsyncTask(onSetup, onDone, CallDoneIf::Success)); - } - m_taskTree.reset(new TaskTree{tasks}); + + const Storage::const_iterator> storage; + const auto onSetup = [this, codeParsers, storage](Async &async) { + async.setConcurrentCallData(parseFileForTests, codeParsers, **storage); + async.setPriority(QThread::LowestPriority); + async.setFutureSynchronizer(&m_futureSynchronizer); + ++*storage; + }; + const auto onDone = [this](const Async &async) { + const QList results = async.results(); + for (const TestParseResultPtr &result : results) + emit testParseResultReady(result); + }; + const Group root { + parallelLimit(limit), + storage, + onGroupSetup([storage, filteredFiles] { *storage = filteredFiles.cbegin(); }), + LoopRepeat(filteredFiles.size()), + AsyncTask(onSetup, onDone, CallDoneIf::Success) + }; + m_taskTree.reset(new TaskTree(root)); connect(m_taskTree.get(), &TaskTree::started, this, &TestCodeParser::parsingStarted); connect(m_taskTree.get(), &TaskTree::done, this, [this](DoneWith result) { m_taskTree.release()->deleteLater();