From 61f6539779db89a318f5a4bc24f4da441f0e08c8 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 31 Oct 2024 13:17:42 +0100 Subject: [PATCH] CMake: Fix detection of help file Amends 7c428e6b5c55f527f51e07be7f1e612d7638d5a2 that broke the detection. Also fix that tool documentation was only detected when restoring existing settings at startup. Fixes: QTCREATORBUG-31927 Change-Id: I85f82a9fc83d7e655bf76d590638ab50d620fb53 Reviewed-by: Christian Stenger --- src/plugins/cmakeprojectmanager/cmaketool.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmaketool.cpp b/src/plugins/cmakeprojectmanager/cmaketool.cpp index 86e7daab9bc..22948083109 100644 --- a/src/plugins/cmakeprojectmanager/cmaketool.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketool.cpp @@ -120,12 +120,10 @@ CMakeTool::CMakeTool(const Store &map, bool fromSdk) : m_isAutoDetected = map.value(CMAKE_INFORMATION_AUTODETECTED, false).toBool(); m_detectionSource = map.value(CMAKE_INFORMATION_DETECTIONSOURCE).toString(); - setFilePath(FilePath::fromSettings(map.value(CMAKE_INFORMATION_COMMAND))); - m_qchFilePath = FilePath::fromSettings(map.value(CMAKE_INFORMATION_QCH_FILE_PATH)); - if (m_qchFilePath.isEmpty()) - m_qchFilePath = searchQchFile(m_executable); + // setFilePath searches for qchFilePath if not already set + setFilePath(FilePath::fromSettings(map.value(CMAKE_INFORMATION_COMMAND))); } CMakeTool::~CMakeTool() = default; @@ -143,6 +141,9 @@ void CMakeTool::setFilePath(const FilePath &executable) m_introspection = std::make_unique(); m_executable = executable; + if (m_qchFilePath.isEmpty()) + m_qchFilePath = searchQchFile(m_executable); + CMakeToolManager::notifyAboutUpdate(this); } @@ -392,8 +393,8 @@ FilePath CMakeTool::searchQchFile(const FilePath &executable) const FilePaths files = docDir.dirEntries(QStringList("*.qch")); for (const FilePath &docFile : files) { - if (docFile.startsWith("cmake")) { - return docDir.resolvePath(docFile).absolutePath(); + if (docFile.fileName().startsWith("cmake", Qt::CaseInsensitive)) { + return docFile.absoluteFilePath(); } }