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 <alessandro.portale@qt.io>
This commit is contained in:
Christiaan Janssen
2022-03-10 10:09:16 +01:00
parent be9b71af2f
commit 75dd1c2251
2 changed files with 3 additions and 3 deletions

View File

@@ -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())

View File

@@ -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();