From d982efc5ae7cddb9c73494a112d3d4b339553f09 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Thu, 2 Jan 2025 21:02:15 +0100 Subject: [PATCH] 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 --- src/plugins/cmakeprojectmanager/fileapireader.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/fileapireader.cpp b/src/plugins/cmakeprojectmanager/fileapireader.cpp index 4409eb73892..e3a36d64208 100644 --- a/src/plugins/cmakeprojectmanager/fileapireader.cpp +++ b/src/plugins/cmakeprojectmanager/fileapireader.cpp @@ -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);