CMakePM: Ensure CMake file-api reply directory watching

The file-api reply watcher was set after CMake was run, and would work
only once, since FileApiReader::setParameters would be called during
handling of FileApiReader::dirty!

This commit makes sure that the ".cmake/api/reply" directory is watched,
not just after an explicit CMake run.

Fixes: QTCREATORBUG-31536
Change-Id: Ifc2706ec1220acd1dccee38d13c3380333758ec1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Cristian Adam
2025-01-02 21:02:15 +01:00
parent b27ed3dc41
commit d982efc5ae

View File

@@ -60,11 +60,12 @@ void FileApiReader::setParameters(const BuildDirParameters &p)
m_parameters = p;
qCDebug(cmakeFileApiMode) << "Work directory:" << m_parameters.buildDirectory.toUserOutput();
// Reset watcher:
m_watcher.clear();
FileApiParser::setupCMakeFileApi(m_parameters.buildDirectory);
const FilePath replyDirectory = FileApiParser::cmakeReplyDirectory(m_parameters.buildDirectory);
if (!m_watcher.watchesDirectory(replyDirectory))
m_watcher.addDirectory(replyDirectory.path(), FileSystemWatcher::WatchAllChanges);
resetData();
}
@@ -383,8 +384,7 @@ void FileApiReader::startCMakeState(const QStringList &configurationArguments)
qCDebug(cmakeFileApiMode) << ">>>>>> Running cmake with arguments:" << configurationArguments;
// Reset watcher:
m_watcher.removeFiles(m_watcher.filePaths());
m_watcher.removeDirectories(m_watcher.directoryPaths());
m_watcher.clear();
makeBackupConfiguration(true);
writeConfigurationIntoBuildDirectory(configurationArguments);