QbsProjectManager: Do not cache incomplete environment

Retrieving the run environment for a qbs product can fail if the qbs
session is busy at the time of the call. In such a case, caching the
result will cause subsequent accesses to retrieve an incomplete
environment. This patch fixes the latter problem.

Task-number: QTCREATORBUG-24599
Change-Id: Ia0c6831cf371995ac8399d15e4dd93b8bb6e4f3b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
Christian Kandeler
2020-10-22 15:58:47 +02:00
parent 98a649ccfd
commit c2913f65e4

View File

@@ -1121,13 +1121,13 @@ void QbsBuildSystem::updateApplicationTargets()
if (result.error().hasError()) {
Core::MessageManager::write(tr("Error retrieving run environment: %1")
.arg(result.error().toString()));
} else {
QProcessEnvironment fullEnv = result.environment();
QTC_ASSERT(!fullEnv.isEmpty(), fullEnv = procEnv);
env = Utils::Environment();
for (const QString &key : fullEnv.keys())
env.set(key, fullEnv.value(key));
return;
}
QProcessEnvironment fullEnv = result.environment();
QTC_ASSERT(!fullEnv.isEmpty(), fullEnv = procEnv);
env = Utils::Environment();
for (const QString &key : fullEnv.keys())
env.set(key, fullEnv.value(key));
m_envCache.insert(key, env);
};