CMakePM: Save document before doing file operations on the CMake

Fixes: QTCREATORBUG-29550
Change-Id: I5ec360a48adce0d51a7fbe1704c7d4a9125bd913
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Cristian Adam
2023-09-03 12:31:25 +02:00
parent 3b11d2605f
commit e892a6224f

View File

@@ -272,6 +272,8 @@ bool CMakeBuildSystem::addFiles(Node *context, const FilePaths &filePaths, FileP
const int targetDefinitionLine = target.backtrace.last().line; const int targetDefinitionLine = target.backtrace.last().line;
// Have a fresh look at the CMake file, not relying on a cached value // Have a fresh look at the CMake file, not relying on a cached value
Core::DocumentManager::saveModifiedDocumentSilently(
Core::DocumentModel::documentForFilePath(targetCMakeFile));
expected_str<QByteArray> fileContent = targetCMakeFile.fileContents(); expected_str<QByteArray> fileContent = targetCMakeFile.fileContents();
cmListFile cmakeListFile; cmListFile cmakeListFile;
std::string errorString; std::string errorString;
@@ -397,6 +399,8 @@ CMakeBuildSystem::projectFileArgumentPosition(const QString &targetName, const Q
const FilePath targetCMakeFile = target.backtrace.last().path; const FilePath targetCMakeFile = target.backtrace.last().path;
// Have a fresh look at the CMake file, not relying on a cached value // Have a fresh look at the CMake file, not relying on a cached value
Core::DocumentManager::saveModifiedDocumentSilently(
Core::DocumentModel::documentForFilePath(targetCMakeFile));
expected_str<QByteArray> fileContent = targetCMakeFile.fileContents(); expected_str<QByteArray> fileContent = targetCMakeFile.fileContents();
cmListFile cmakeListFile; cmListFile cmakeListFile;
std::string errorString; std::string errorString;