ClangCodeModel: Allow empty project info list

... when generating compilation database.
This can happen in session mode.

Fixes: QTCREATORBUG-31186
Change-Id: Ieb081932ac2c562bacae995c7d05a3e0e96c9153
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2024-07-04 19:14:56 +02:00
parent 412eeefafa
commit 1fd7056840

View File

@@ -157,8 +157,6 @@ void generateCompilationDB(
{ {
QTC_ASSERT(!baseDir.isEmpty(), QTC_ASSERT(!baseDir.isEmpty(),
promise.addResult(make_unexpected(Tr::tr("Could not retrieve build directory."))); return); promise.addResult(make_unexpected(Tr::tr("Could not retrieve build directory."))); return);
QTC_ASSERT(!projectInfoList.isEmpty(),
promise.addResult(make_unexpected(Tr::tr("Could not retrieve project info."))); return);
QTC_CHECK(baseDir.ensureWritableDir()); QTC_CHECK(baseDir.ensureWritableDir());
QFile compileCommandsFile(baseDir.pathAppended("compile_commands.json").toFSPathString()); QFile compileCommandsFile(baseDir.pathAppended("compile_commands.json").toFSPathString());
const bool fileOpened = compileCommandsFile.open(QIODevice::WriteOnly | QIODevice::Truncate); const bool fileOpened = compileCommandsFile.open(QIODevice::WriteOnly | QIODevice::Truncate);