From 65a6853aec7b28643f4de7d76fc08a0c66cb44f2 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 23 Feb 2022 12:17:34 +0100 Subject: [PATCH] QbsPM: Avoid QFileInfo for paths that may non-local Change-Id: I08b0b2c298c8f175e0c0a2d5e87691354afa46e5 Reviewed-by: Christian Kandeler --- .../defaultpropertyprovider.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp index 4079b0ef56b..19bfdc27b0a 100644 --- a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp +++ b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp @@ -313,22 +313,20 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor if (tcCxx) cxxCompilerPath = tcCxx->compilerCommand(); - const QFileInfo cFileInfo = cCompilerPath.toFileInfo(); - const QFileInfo cxxFileInfo = cxxCompilerPath.toFileInfo(); - QString cCompilerName = cFileInfo.fileName(); - QString cxxCompilerName = cxxFileInfo.fileName(); + QString cCompilerName = cCompilerPath.fileName(); + QString cxxCompilerName = cxxCompilerPath.fileName(); const QString cToolchainPrefix = extractToolchainPrefix(&cCompilerName); const QString cxxToolchainPrefix = extractToolchainPrefix(&cxxCompilerName); - QFileInfo mainFileInfo; + Utils::FilePath mainFilePath; QString mainCompilerName; QString mainToolchainPrefix; if (tcCxx) { - mainFileInfo = cxxFileInfo; + mainFilePath = cxxCompilerPath; mainCompilerName = cxxCompilerName; mainToolchainPrefix = cxxToolchainPrefix; } else { - mainFileInfo = cFileInfo; + mainFilePath = cCompilerPath; mainCompilerName = cCompilerName; mainToolchainPrefix = cToolchainPrefix; } @@ -353,11 +351,11 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor } if (tcC && tcCxx && !cCompilerPath.isEmpty() && !cxxCompilerPath.isEmpty() - && cFileInfo.absolutePath() != cxxFileInfo.absolutePath()) { + && cCompilerPath.absolutePath() != cxxCompilerPath.absolutePath()) { Core::MessageManager::writeFlashing( tr("C and C++ compiler paths differ. C compiler may not work.")); } - data.insert(QLatin1String(CPP_TOOLCHAINPATH), mainFileInfo.absolutePath()); + data.insert(QLatin1String(CPP_TOOLCHAINPATH), mainFilePath.absolutePath().toString()); if (auto gcc = dynamic_cast(mainTc)) { QStringList compilerFlags = gcc->platformCodeGenFlags(); @@ -372,7 +370,7 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor // Reverse engineer the Xcode developer path from the compiler path const QRegularExpression compilerRe( QStringLiteral("^(?.*)/Toolchains/(?:.+)\\.xctoolchain/usr/bin$")); - const QRegularExpressionMatch compilerReMatch = compilerRe.match(cxxFileInfo.absolutePath()); + const QRegularExpressionMatch compilerReMatch = compilerRe.match(cxxCompilerPath.absolutePath().toString()); if (compilerReMatch.hasMatch()) { const QString developerPath = compilerReMatch.captured(QStringLiteral("developerpath")); data.insert(QLatin1String(XCODE_DEVELOPERPATH), developerPath);