forked from qt-creator/qt-creator
qmake: Prevent injection of empty values via environment variables
The qmake $() operator retrieves environment values at make time. In Qt Creator, we still use these values for feeding the code model, presumably because the qmake and make step share a common environment. However, we must take care that unset environment values do not lead to empty strings in qmake lists, as that can have unwanted side effects, especially when these lists get turned into command line arguments that are passed to build tools. A concrete example: A project file contained the following assignment: QMAKE_CXXFLAGS += $(SOME_VAR) SOME_VAR was not set in the environment, so an additional empty argument appeared on the command line when the code model called the MSVC compiler to retrieve some information required for parsing the code. The call failed, the code model had to fall back to default values, and the user got parsing errors. Fixes: QTCREATORBUG-21729 Change-Id: I224369a2fb9c0dd78406253edba03bd44556be44 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
@@ -71,8 +71,11 @@ QStringList ProFileEvaluator::values(const QString &variableName) const
|
||||
const ProStringList &values = d->values(ProKey(variableName));
|
||||
QStringList ret;
|
||||
ret.reserve(values.size());
|
||||
foreach (const ProString &str, values)
|
||||
ret << d->m_option->expandEnvVars(str.toQString());
|
||||
for (const ProString &str : values) {
|
||||
const QString expanded = d->m_option->expandEnvVars(str.toQString());
|
||||
if (!expanded.isEmpty() || str.isEmpty())
|
||||
ret << expanded;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user