ProjectExplorer: Handle registering of auto-created bundle toolchains

... in the bundle itself, whenever possible.
It's very annoying to have to add this stanza in all places where
bundling takes place, and it's also easily forgotten, introducing memory
leaks.
This also nicely self-documents the expectations of the calling code as
to whether new toolchains can or cannot be created in the given context
as a side effect of bundling.

Change-Id: I78d2d4cdfc1010568f61f201b0d930b01f79a88b
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2024-08-08 13:58:28 +02:00
parent bdf21f9dde
commit 077de5aab6
9 changed files with 66 additions and 51 deletions

View File

@@ -271,8 +271,10 @@ private:
return !tc->compilerCommand().isSameDevice(device->rootPath());
});
const QList<ToolchainBundle> sameBundles = ToolchainBundle::collectBundles(same);
const QList<ToolchainBundle> otherBundles = ToolchainBundle::collectBundles(other);
const QList<ToolchainBundle> sameBundles
= ToolchainBundle::collectBundles(same, ToolchainBundle::AutoRegister::On);
const QList<ToolchainBundle> otherBundles
= ToolchainBundle::collectBundles(other, ToolchainBundle::AutoRegister::On);
for (const ToolchainBundle &b : sameBundles)
cb->addItem(b.displayName(), b.bundleId().toSetting());
@@ -453,9 +455,8 @@ static void setToolchainsFromAbis(Kit *k, const LanguagesAndAbis &abisByLanguage
}
// Get bundles.
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles();
for (const ToolchainBundle &b : bundles)
ToolchainManager::registerToolchains(b.createdToolchains());
const QList<ToolchainBundle> bundles = ToolchainBundle::collectBundles(
ToolchainBundle::AutoRegister::On);
// Set a matching bundle for each LanguageCategory/Abi pair, if possible.
for (auto it = abisByCategory.cbegin(); it != abisByCategory.cend(); ++it) {