forked from qt-creator/qt-creator
Utils: Replace Environment.isValid() with .hasChanges()
That's closer to the intended semantics. The "other" use in docker will be changed to an optional<Environment> as follow-up to keep this here mechanical. Change-Id: I43ef9da6c9c7731b28f9d6fab6413ce9c4f428b4 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -23,7 +23,7 @@ NameValueItems Environment::diff(const Environment &other, bool checkAppendPrepe
|
||||
return m_dict.diff(other.m_dict, checkAppendPrepend);
|
||||
}
|
||||
|
||||
int Environment::isValid() const
|
||||
bool Environment::hasChanges() const
|
||||
{
|
||||
return m_dict.size() != 0;
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public:
|
||||
void unset(const QString &key) { m_dict.unset(key); }
|
||||
void modify(const NameValueItems &items) { m_dict.modify(items); }
|
||||
|
||||
int isValid() const;
|
||||
bool hasChanges() const;
|
||||
void clear() { return m_dict.clear(); }
|
||||
|
||||
QStringList toStringList() const { return m_dict.toStringList(); }
|
||||
|
@@ -668,7 +668,7 @@ public:
|
||||
Environment fullEnvironment() const
|
||||
{
|
||||
Environment env = m_setup.m_environment;
|
||||
if (!env.isValid()) {
|
||||
if (!env.hasChanges()) {
|
||||
// FIXME: Either switch to using EnvironmentChange instead of full Environments, or
|
||||
// feed the full environment into the QtcProcess instead of fixing it up here.
|
||||
// qWarning("QtcProcess::start: Empty environment set when running '%s'.",
|
||||
@@ -1190,7 +1190,7 @@ QString QtcProcess::toStandaloneCommandLine() const
|
||||
d->m_setup.m_workingDirectory.path();
|
||||
}
|
||||
parts.append("-i");
|
||||
if (d->m_setup.m_environment.isValid()) {
|
||||
if (d->m_setup.m_environment.hasChanges()) {
|
||||
const QStringList envVars = d->m_setup.m_environment.toStringList();
|
||||
std::transform(envVars.cbegin(), envVars.cend(),
|
||||
std::back_inserter(parts), ProcessArgs::quoteArgUnix);
|
||||
|
@@ -605,7 +605,7 @@ void AndroidRunnerWorker::asyncStartHelper()
|
||||
<< QString::fromLatin1(appArgs.join(' ').toUtf8().toBase64());
|
||||
}
|
||||
|
||||
if (m_extraEnvVars.isValid()) {
|
||||
if (m_extraEnvVars.hasChanges()) {
|
||||
args << "-e" << "extraenvvars"
|
||||
<< QString::fromLatin1(m_extraEnvVars.toStringList().join('\t')
|
||||
.toUtf8().toBase64());
|
||||
|
@@ -61,7 +61,7 @@ FilePath ITestConfiguration::executableFilePath() const
|
||||
if (!hasExecutable())
|
||||
return {};
|
||||
|
||||
const Environment env = m_runnable.environment.isValid()
|
||||
const Environment env = m_runnable.environment.hasChanges()
|
||||
? m_runnable.environment : Environment::systemEnvironment();
|
||||
return env.searchInPath(m_runnable.command.executable().path());
|
||||
}
|
||||
|
@@ -146,7 +146,7 @@ static Environment projectBuildEnvironment(Project *project)
|
||||
if (BuildConfiguration *buildConfig = target->activeBuildConfiguration())
|
||||
env = buildConfig->environment();
|
||||
}
|
||||
if (!env.isValid())
|
||||
if (!env.hasChanges())
|
||||
env = Environment::systemEnvironment();
|
||||
return env;
|
||||
}
|
||||
|
@@ -411,7 +411,7 @@ void CdbEngine::setupEngine()
|
||||
|
||||
m_autoBreakPointCorrection = false;
|
||||
|
||||
Environment inferiorEnvironment = sp.inferior.environment.isValid()
|
||||
Environment inferiorEnvironment = sp.inferior.environment.hasChanges()
|
||||
? sp.inferior.environment : Environment::systemEnvironment();
|
||||
|
||||
// Make sure that QTestLib uses OutputDebugString for logging.
|
||||
|
@@ -1137,10 +1137,10 @@ bool DockerDevicePrivate::addTemporaryMount(const FilePath &path, const FilePath
|
||||
|
||||
Environment DockerDevicePrivate::environment()
|
||||
{
|
||||
if (!m_cachedEnviroment.isValid())
|
||||
if (!m_cachedEnviroment.hasChanges())
|
||||
fetchSystemEnviroment();
|
||||
|
||||
QTC_CHECK(m_cachedEnviroment.isValid());
|
||||
QTC_CHECK(m_cachedEnviroment.hasChanges());
|
||||
return m_cachedEnviroment;
|
||||
}
|
||||
|
||||
|
@@ -113,7 +113,7 @@ void StdIOClientInterface::startImpl()
|
||||
m_logFile.write(QString("Starting server: %1\nOutput:\n\n").arg(m_cmd.toUserOutput()).toUtf8());
|
||||
m_process->setCommand(m_cmd);
|
||||
m_process->setWorkingDirectory(m_workingDirectory);
|
||||
if (m_env.isValid())
|
||||
if (m_env.hasChanges())
|
||||
m_process->setEnvironment(m_env);
|
||||
m_process->start();
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@ QStringList SshParameters::connectionOptions(const FilePath &binary) const
|
||||
bool SshParameters::setupSshEnvironment(QtcProcess *process)
|
||||
{
|
||||
Environment env = process->controlEnvironment();
|
||||
if (!env.isValid())
|
||||
if (!env.hasChanges())
|
||||
env = Environment::systemEnvironment();
|
||||
const bool hasDisplay = env.hasKey("DISPLAY") && (env.value("DISPLAY") != QString(":0"));
|
||||
if (SshSettings::askpassFilePath().exists()) {
|
||||
|
@@ -1154,7 +1154,7 @@ ToolChain::BuiltInHeaderPathsRunner MsvcToolChain::createBuiltInHeaderPathsRunne
|
||||
void MsvcToolChain::addToEnvironment(Utils::Environment &env) const
|
||||
{
|
||||
// We cache the full environment (incoming + modifications by setup script).
|
||||
if (!m_resultEnvironment.isValid() || env != m_lastEnvironment) {
|
||||
if (!m_resultEnvironment.hasChanges() || env != m_lastEnvironment) {
|
||||
qCDebug(Log) << "addToEnvironment: " << displayName();
|
||||
m_lastEnvironment = env;
|
||||
m_resultEnvironment = readEnvironmentSetting(env);
|
||||
|
@@ -170,7 +170,7 @@ bool MakeInstallStep::init()
|
||||
}
|
||||
|
||||
const MakeInstallCommand cmd = buildSystem()->makeInstallCommand(rootDir);
|
||||
if (cmd.environment.isValid()) {
|
||||
if (cmd.environment.hasChanges()) {
|
||||
Environment env = processParameters()->environment();
|
||||
for (auto it = cmd.environment.constBegin(); it != cmd.environment.constEnd(); ++it) {
|
||||
if (cmd.environment.isEnabled(it)) {
|
||||
|
Reference in New Issue
Block a user