CppTools: Optionally move raw project parts creation into thread

... by letting callers pass in a generator function.
This takes some load off the UI thread for larger projects.
For now only used by the QbsProjectManager, which can provide a thread-
safe generator function due to the project data existing in "value"
form.

Task-number: QTCREATORBUG-18533
Change-Id: I525dea36a4c4079bd1bd5a4fff844617547d56f1
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2020-02-04 12:27:58 +01:00
parent fd8187cb86
commit cd9571b4f7
4 changed files with 42 additions and 16 deletions

View File

@@ -61,7 +61,10 @@ void CppProjectUpdater::update(const ProjectExplorer::ProjectUpdateInfo &project
// Run the project info generator in a worker thread and continue if that one is finished.
const QFuture<ProjectInfo> future = Utils::runAsync([=]() {
Internal::ProjectInfoGenerator generator(m_futureInterface, projectUpdateInfo);
ProjectUpdateInfo fullProjectUpdateInfo = projectUpdateInfo;
if (fullProjectUpdateInfo.rppGenerator)
fullProjectUpdateInfo.rawProjectParts = fullProjectUpdateInfo.rppGenerator();
Internal::ProjectInfoGenerator generator(m_futureInterface, fullProjectUpdateInfo);
return generator.generate();
});
m_generateFutureWatcher.setFuture(future);