From 75dd1c225180391bafbeb190ab9414bd576867bb Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Thu, 10 Mar 2022 10:09:16 +0100 Subject: [PATCH] McuSupport: fix issue with resolving relative paths FilePath::resolvePath accepts a FilePath param, but treats leading hashes as indication of an absolute path. FilePath::pathAppended only accepts QString, but understands that the param is always a relative path. In our case we always want to treat the paths as relative. Change-Id: Ib23c27e76500de8a89d9dd22cd7efb95a9bd4d6d Reviewed-by: Alessandro Portale --- src/plugins/mcusupport/mcupackage.cpp | 4 ++-- src/plugins/mcusupport/mcusupportversiondetection.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/mcusupport/mcupackage.cpp b/src/plugins/mcusupport/mcupackage.cpp index f4ca09355e4..9d717b3154d 100644 --- a/src/plugins/mcusupport/mcupackage.cpp +++ b/src/plugins/mcusupport/mcupackage.cpp @@ -98,7 +98,7 @@ FilePath McuPackage::basePath() const FilePath McuPackage::path() const { - return basePath().resolvePath(m_relativePathModifier).absoluteFilePath(); + return basePath().pathAppended(m_relativePathModifier.path()).absoluteFilePath(); } FilePath McuPackage::defaultPath() const @@ -121,7 +121,7 @@ void McuPackage::updatePath() void McuPackage::updateStatus() { bool validPath = !m_path.isEmpty() && m_path.exists(); - const FilePath detectionPath = basePath().resolvePath(m_detectionPath); + const FilePath detectionPath = basePath().pathAppended(m_detectionPath.path()); const bool validPackage = m_detectionPath.isEmpty() || detectionPath.exists(); m_detectedVersion = validPath && validPackage && m_versionDetector ? m_versionDetector->parseVersion(basePath().toString()) diff --git a/src/plugins/mcusupport/mcusupportversiondetection.cpp b/src/plugins/mcusupport/mcusupportversiondetection.cpp index 5380446a134..12bb7912e72 100644 --- a/src/plugins/mcusupport/mcusupportversiondetection.cpp +++ b/src/plugins/mcusupport/mcusupportversiondetection.cpp @@ -58,7 +58,7 @@ QString McuPackageExecutableVersionDetector::parseVersion(const QString &package if (m_detectionPath.isEmpty() || m_detectionRegExp.isEmpty()) return QString(); - const Utils::FilePath binaryPath = Utils::FilePath::fromString(packagePath).resolvePath(m_detectionPath); + const Utils::FilePath binaryPath = Utils::FilePath::fromString(packagePath).pathAppended(m_detectionPath.path()); if (!binaryPath.exists()) return QString();