ClangUtils: Get rid of GenerateCompilationDbResult struct

Replace it with expected_str<FilePath>.
Check periodically for cancel request inside
generateCompilationDB() body.

Cancel the possibly running task on ClangCodeModelPlugin
destruction.

Handle the cancellation.

Change-Id: I8bcb956bc03627b4a17a3510a76810e66c82815d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2024-05-23 23:41:17 +02:00
parent d3b2bc32cc
commit 63a93760d9
4 changed files with 45 additions and 38 deletions

View File

@@ -540,11 +540,15 @@ void ClangModelManagerSupport::updateLanguageClient(Project *project)
generatorWatcher->deleteLater();
if (!isProjectDataUpToDate(project, projectInfo, jsonDbDir))
return;
const GenerateCompilationDbResult result = generatorWatcher->result();
if (!result.error.isEmpty()) {
if (generatorWatcher->future().resultCount() == 0) {
MessageManager::writeDisrupting(
Tr::tr("Cannot use clangd: Failed to generate compilation database:\n%1")
.arg(result.error));
Tr::tr("Cannot use clangd: Generating compilation database canceled."));
return;
}
const GenerateCompilationDbResult result = generatorWatcher->result();
if (!result) {
MessageManager::writeDisrupting(Tr::tr("Cannot use clangd: "
"Failed to generate compilation database:\n%1").arg(result.error()));
return;
}
Id previousId;