ClangCodeModel: prevent crash on null project info

Change-Id: Iff0c0413aa52821dc883b7f42b04bc8ca5dd4a29
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
David Schulz
2022-03-11 12:40:14 +01:00
parent 1de60ddeaf
commit 8e16d45d4c

View File

@@ -379,6 +379,8 @@ GenerateCompilationDbResult generateCompilationDB(const CppEditor::ProjectInfo::
{
QTC_ASSERT(!baseDir.isEmpty(), return GenerateCompilationDbResult(QString(),
QCoreApplication::translate("ClangUtils", "Could not retrieve build directory.")));
QTC_ASSERT(projectInfo, return GenerateCompilationDbResult(QString(),
"Could not retrieve project info."));
QTC_CHECK(baseDir.ensureWritableDir());
QFile compileCommandsFile(baseDir.toString() + "/compile_commands.json");
const bool fileOpened = compileCommandsFile.open(QIODevice::WriteOnly | QIODevice::Truncate);