Utils: Remove one ProcessArgs::expandMacros overload

Only used once.

Also allow logging of expansion failures.

Change-Id: I357ed6ed28fe379d482358c46b495bc727f86902
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-07-06 09:12:35 +02:00
parent 86df204bad
commit 4eec360563
3 changed files with 7 additions and 10 deletions

View File

@@ -1089,13 +1089,6 @@ bool ProcessArgs::expandMacros(QString *cmd, AbstractMacroExpander *mx, OsType o
return true; return true;
} }
QString ProcessArgs::expandMacros(const QString &str, AbstractMacroExpander *mx, OsType osType)
{
QString ret = str;
expandMacros(&ret, mx, osType);
return ret;
}
bool ProcessArgs::ArgIterator::next() bool ProcessArgs::ArgIterator::next()
{ {
// We delay the setting of m_prev so we can still delete the last argument // We delay the setting of m_prev so we can still delete the last argument

View File

@@ -81,8 +81,6 @@ public:
//! Safely replace the expandos in a shell command //! Safely replace the expandos in a shell command
static bool expandMacros(QString *cmd, AbstractMacroExpander *mx, static bool expandMacros(QString *cmd, AbstractMacroExpander *mx,
OsType osType = HostOsInfo::hostOs()); OsType osType = HostOsInfo::hostOs());
static QString expandMacros(const QString &str, AbstractMacroExpander *mx,
OsType osType = HostOsInfo::hostOs());
/*! Iterate over arguments from a command line. /*! Iterate over arguments from a command line.
* Assumes that the name of the actual command is *not* part of the line. * Assumes that the name of the actual command is *not* part of the line.

View File

@@ -35,11 +35,14 @@
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
#include <QLoggingCategory>
#include <QMap> #include <QMap>
namespace Utils { namespace Utils {
namespace Internal { namespace Internal {
static Q_LOGGING_CATEGORY(expanderLog, "qtc.utils.macroexpander", QtWarningMsg)
const char kFilePathPostfix[] = ":FilePath"; const char kFilePathPostfix[] = ":FilePath";
const char kPathPostfix[] = ":Path"; const char kPathPostfix[] = ":Path";
const char kNativeFilePathPostfix[] = ":NativeFilePath"; const char kNativeFilePathPostfix[] = ":NativeFilePath";
@@ -327,7 +330,10 @@ QVariant MacroExpander::expandVariant(const QVariant &v) const
QString MacroExpander::expandProcessArgs(const QString &argsWithVariables) const QString MacroExpander::expandProcessArgs(const QString &argsWithVariables) const
{ {
return ProcessArgs::expandMacros(argsWithVariables, d); QString result = argsWithVariables;
const bool ok = ProcessArgs::expandMacros(&result, d);
QTC_ASSERT(ok, qCDebug(expanderLog) << "Expanding failed: " << argsWithVariables);
return result;
} }
static QByteArray fullPrefix(const QByteArray &prefix) static QByteArray fullPrefix(const QByteArray &prefix)