forked from qt-creator/qt-creator
Utils: use system case for environment variables on windows
Match case of user changed environment variables to the already defined variables. Change-Id: Ic012d35faa0822df3523ab642491c9f19051853c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -500,7 +500,7 @@ Environment::const_iterator Environment::constEnd() const
|
||||
|
||||
Environment::const_iterator Environment::constFind(const QString &name) const
|
||||
{
|
||||
return m_values.constFind(name);
|
||||
return findKey(m_values, m_osType, name);
|
||||
}
|
||||
|
||||
int Environment::size() const
|
||||
@@ -567,6 +567,11 @@ bool Environment::hasKey(const QString &key) const
|
||||
return m_values.contains(key);
|
||||
}
|
||||
|
||||
OsType Environment::osType() const
|
||||
{
|
||||
return m_osType;
|
||||
}
|
||||
|
||||
QString Environment::userName() const
|
||||
{
|
||||
return value(QString::fromLatin1(m_osType == OsTypeWindows ? "USERNAME" : "USER"));
|
||||
|
||||
@@ -91,6 +91,7 @@ public:
|
||||
/// Return the Environment changes necessary to modify this into the other environment.
|
||||
QList<EnvironmentItem> diff(const Environment &other, bool checkAppendPrepend = false) const;
|
||||
bool hasKey(const QString &key) const;
|
||||
OsType osType() const;
|
||||
|
||||
QString userName() const;
|
||||
|
||||
|
||||
@@ -364,6 +364,13 @@ void EnvironmentModel::setUserChanges(QList<EnvironmentItem> list)
|
||||
name = name.trimmed();
|
||||
if (name.startsWith(QLatin1String("export ")))
|
||||
name = name.mid(7).trimmed();
|
||||
if (d->m_baseEnvironment.osType() == OsTypeWindows) {
|
||||
// Environment variable names are case-insensitive under windows, but we still
|
||||
// want to preserve the case of pre-existing variables.
|
||||
auto it = d->m_baseEnvironment.constFind(name);
|
||||
if (it != d->m_baseEnvironment.constEnd())
|
||||
name = d->m_baseEnvironment.key(it);
|
||||
}
|
||||
}
|
||||
|
||||
d->updateResultEnvironment();
|
||||
|
||||
Reference in New Issue
Block a user