BuildConfiguration: Do not update environment cache in constructor

Updating the environment cache calls into the virtual function
BuildConfiguration::addToEnvironment (via BC::baseEnvironment()), and
that is not working in the constructor yet.

Move the call to updateCacheAndEmitEnvironmentChanged to
BC::doInitialize.

This fixes the build environment for the first CMake run on a newly
created project. CMakeBuildConfiguration::addToEnvironment adds the PATH
to the Ninja installation from the online installer. If that is missing,
CMake will fail with a missing build tool, if Ninja isn't found anywhere
else.

Amends 65e043961e

Task-number: QTCREATORBUG-27495
Change-Id: I7c952db9029ab78e0aa9ea267444af163f5941ac
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2022-07-13 13:46:16 +02:00
parent c92216aea5
commit 550a7ecc6e

View File

@@ -201,7 +201,6 @@ BuildConfiguration::BuildConfiguration(Target *target, Utils::Id id)
tr("Variables in the build configuration's environment"),
[this](const QString &var) { return environment().expandedValueForKey(var); });
updateCacheAndEmitEnvironmentChanged();
connect(Core::ICore::instance(), &Core::ICore::systemEnvironmentChanged,
this, &BuildConfiguration::updateCacheAndEmitEnvironmentChanged);
connect(target, &Target::kitChanged,
@@ -292,6 +291,8 @@ void BuildConfiguration::addConfigWidgets(const std::function<void(NamedWidget *
void BuildConfiguration::doInitialize(const BuildInfo &info)
{
updateCacheAndEmitEnvironmentChanged();
setDisplayName(info.displayName);
setDefaultDisplayName(info.displayName);
setBuildDirectory(info.buildDirectory);