diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index 66daf7b4c30..ecdb290c6b0 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -1459,7 +1459,7 @@ void AndroidConfigurations::updateAutomaticKitList() ToolchainManager::toolchains([](const Toolchain *tc) { return tc->isAutoDetected() && tc->typeId() == Constants::ANDROID_TOOLCHAIN_TYPEID; }), - ToolchainBundle::AutoRegister::On), + ToolchainBundle::HandleMissing::CreateAndRegister), [](const ToolchainBundle &b) { return b.isCompletelyValid(); }); QList unhandledKits = existingKits; diff --git a/src/plugins/docker/kitdetector.cpp b/src/plugins/docker/kitdetector.cpp index 51856408f87..8e476cdb557 100644 --- a/src/plugins/docker/kitdetector.cpp +++ b/src/plugins/docker/kitdetector.cpp @@ -265,8 +265,8 @@ Toolchains KitDetectorPrivate::autoDetectToolchains() toolchain->setDetectionSource(m_sharedId); } ToolchainManager::registerToolchains(newToolchains); - const QList bundles - = ToolchainBundle::collectBundles(newToolchains, ToolchainBundle::AutoRegister::On); + const QList bundles = ToolchainBundle::collectBundles( + newToolchains, ToolchainBundle::HandleMissing::CreateAndRegister); alreadyKnown.append(newToolchains); allNewToolchains.append(newToolchains); } @@ -358,8 +358,8 @@ void KitDetectorPrivate::autoDetect() const Toolchains toolchainCandidates = ToolchainManager::toolchains( [this](const Toolchain *tc) { return tc->detectionSource() == m_sharedId; }); - const QList bundles - = ToolchainBundle::collectBundles(toolchainCandidates, ToolchainBundle::AutoRegister::On); + const QList bundles = ToolchainBundle::collectBundles( + toolchainCandidates, ToolchainBundle::HandleMissing::CreateAndRegister); // Try to find a matching Qt/Toolchain pair. bool match = false; diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index 831e4aa35d7..7dbae83b62f 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -2136,7 +2136,7 @@ void GccToolchainConfigWidget::updateParentToolchainComboBox() if (bundle().isAutoDetected() || m_parentToolchainCombo->count() == 0) parentBundleId = bundleIdFromId(bundle().get(&GccToolchain::parentToolchainId)); const QList mingwBundles = Utils::filtered( - ToolchainBundle::collectBundles(ToolchainBundle::AutoRegister::NotApplicable), + ToolchainBundle::collectBundles(ToolchainBundle::HandleMissing::NotApplicable), [](const ToolchainBundle &b) { return b.type() == Constants::MINGW_TOOLCHAIN_TYPEID; }); const auto parentBundle = Utils::findOr(mingwBundles, std::nullopt, [parentBundleId](const ToolchainBundle &b) { diff --git a/src/plugins/projectexplorer/kitmanager.cpp b/src/plugins/projectexplorer/kitmanager.cpp index 9ee117f9883..a7484dc06e5 100644 --- a/src/plugins/projectexplorer/kitmanager.cpp +++ b/src/plugins/projectexplorer/kitmanager.cpp @@ -254,7 +254,7 @@ void KitManager::restoreKits() QHash>> uniqueToolchains; const QList bundles = ToolchainBundle::collectBundles( - ToolchainBundle::AutoRegister::On); + ToolchainBundle::HandleMissing::CreateAndRegister); for (const ToolchainBundle &bundle : bundles) { auto &bestBundle = uniqueToolchains[bundle.targetAbi()][bundle.factory()->languageCategory()]; diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index ce4b4c05143..7239f408398 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -1659,7 +1659,7 @@ void ClangClToolchainConfigWidget::applyImpl() const QString displayedVarsBat = m_varsBatDisplayCombo->currentText(); Toolchains results = detectClangClToolChainInPath(clangClPath, {}, displayedVarsBat); const QList bundles - = ToolchainBundle::collectBundles(results, ToolchainBundle::AutoRegister::NotApplicable); + = ToolchainBundle::collectBundles(results, ToolchainBundle::HandleMissing::NotApplicable); if (bundles.isEmpty()) { bundle().set(&ClangClToolchain::resetVarsBat); diff --git a/src/plugins/projectexplorer/toolchain.cpp b/src/plugins/projectexplorer/toolchain.cpp index 420532ef48a..5f6c48fea56 100644 --- a/src/plugins/projectexplorer/toolchain.cpp +++ b/src/plugins/projectexplorer/toolchain.cpp @@ -915,7 +915,7 @@ void AsyncToolchainDetector::run() * - There is exactly one toolchain in the list for every language supported by the factory. * - If there is a C compiler, it comes first in the list. */ -ToolchainBundle::ToolchainBundle(const Toolchains &toolchains, AutoRegister autoRegister) +ToolchainBundle::ToolchainBundle(const Toolchains &toolchains, HandleMissing handleMissing) : m_toolchains(toolchains) { // Check pre-conditions. @@ -930,7 +930,7 @@ ToolchainBundle::ToolchainBundle(const Toolchains &toolchains, AutoRegister auto QTC_ASSERT(tc->bundleId() == toolchains.first()->bundleId(), return); } - addMissingToolchains(autoRegister); + addMissingToolchains(handleMissing); // Check post-conditions. QTC_ASSERT(m_toolchains.size() == m_toolchains.first()->factory()->supportedLanguages().size(), @@ -943,13 +943,13 @@ ToolchainBundle::ToolchainBundle(const Toolchains &toolchains, AutoRegister auto }); } -QList ToolchainBundle::collectBundles(AutoRegister autoRegister) +QList ToolchainBundle::collectBundles(HandleMissing handleMissing) { - return collectBundles(ToolchainManager::toolchains(), autoRegister); + return collectBundles(ToolchainManager::toolchains(), handleMissing); } QList ToolchainBundle::collectBundles( - const Toolchains &toolchains, AutoRegister autoRegister) + const Toolchains &toolchains, HandleMissing handleMissing) { QHash toolchainsPerBundleId; for (Toolchain * const tc : toolchains) @@ -958,12 +958,12 @@ QList ToolchainBundle::collectBundles( QList bundles; if (const auto unbundled = toolchainsPerBundleId.constFind(Id()); unbundled != toolchainsPerBundleId.constEnd()) { - bundles = bundleUnbundledToolchains(*unbundled, autoRegister); + bundles = bundleUnbundledToolchains(*unbundled, handleMissing); toolchainsPerBundleId.erase(unbundled); } for (const Toolchains &tcs : toolchainsPerBundleId) - bundles.emplaceBack(tcs, autoRegister); + bundles.emplaceBack(tcs, handleMissing); return bundles; } @@ -1010,8 +1010,7 @@ ToolchainBundle::Valid ToolchainBundle::validity() const return Valid::None; } -QList ToolchainBundle::bundleUnbundledToolchains( - const Toolchains &unbundled, AutoRegister autoRegister) +QList ToolchainBundle::bundleUnbundledToolchains(const Toolchains &unbundled, HandleMissing handleMissing) { QList bundles; QHash> unbundledByTypeAndLanguage; @@ -1037,7 +1036,7 @@ QList ToolchainBundle::bundleUnbundledToolchains( const Id newBundleId = Id::generate(); for (Toolchain * const tc : nextBundle) tc->setBundleId(newBundleId); - bundles.emplaceBack(nextBundle, autoRegister); + bundles.emplaceBack(nextBundle, handleMissing); } } @@ -1075,10 +1074,10 @@ ToolchainBundle ToolchainBundle::clone() const const Id newBundleId = Id::generate(); for (Toolchain * const tc : clones) tc->setBundleId(newBundleId); - return ToolchainBundle(clones, ToolchainBundle::AutoRegister::NotApplicable); + return ToolchainBundle(clones, ToolchainBundle::HandleMissing::NotApplicable); } -void ToolchainBundle::addMissingToolchains(AutoRegister autoRegister) +void ToolchainBundle::addMissingToolchains(HandleMissing handleMissing) { const QList missingLanguages = Utils::filtered(m_toolchains.first()->factory()->supportedLanguages(), [this](Id lang) { @@ -1095,12 +1094,12 @@ void ToolchainBundle::addMissingToolchains(AutoRegister autoRegister) createdToolchains << tc; } - switch (autoRegister) { - case AutoRegister::On: + switch (handleMissing) { + case HandleMissing::CreateAndRegister: ToolchainManager::registerToolchains(createdToolchains); - case AutoRegister::Off: + case HandleMissing::CreateOnly: break; - case AutoRegister::NotApplicable: + case HandleMissing::NotApplicable: QTC_CHECK(createdToolchains.isEmpty()); break; } diff --git a/src/plugins/projectexplorer/toolchain.h b/src/plugins/projectexplorer/toolchain.h index bb08d04dcf5..fe0ae0e935b 100644 --- a/src/plugins/projectexplorer/toolchain.h +++ b/src/plugins/projectexplorer/toolchain.h @@ -230,13 +230,15 @@ public: // Setting up a bundle may necessitate creating additional toolchains. // Depending on the context, these should or should not be registered // immediately with the ToolchainManager. - enum class AutoRegister { On, Off, NotApplicable }; + // In the case of NotApplicable, the caller promises that no toolchains + // will need to be created to ensure a complete bundle. + enum class HandleMissing { CreateAndRegister, CreateOnly, NotApplicable }; - ToolchainBundle(const Toolchains &toolchains, AutoRegister autoRegister); + ToolchainBundle(const Toolchains &toolchains, HandleMissing handleMissing); - static QList collectBundles(AutoRegister autoRegister); + static QList collectBundles(HandleMissing handleMissing); static QList collectBundles( - const Toolchains &toolchains, AutoRegister autoRegister); + const Toolchains &toolchains, HandleMissing handleMissing); template R get(R (T:: *getter)(A...) const, A&&... args) const @@ -315,9 +317,9 @@ public: } private: - void addMissingToolchains(AutoRegister autoRegister); + void addMissingToolchains(HandleMissing handleMissing); static QList bundleUnbundledToolchains( - const Toolchains &unbundled, AutoRegister autoRegister); + const Toolchains &unbundled, HandleMissing handleMissing); Toolchains m_toolchains; }; diff --git a/src/plugins/projectexplorer/toolchainkitaspect.cpp b/src/plugins/projectexplorer/toolchainkitaspect.cpp index 800f4dcade4..77668bf558d 100644 --- a/src/plugins/projectexplorer/toolchainkitaspect.cpp +++ b/src/plugins/projectexplorer/toolchainkitaspect.cpp @@ -50,7 +50,7 @@ public: return tc->compilerCommand().isSameDevice(device->rootPath()); }); const QList bundlesForBuildDevice = ToolchainBundle::collectBundles( - toolchainsForBuildDevice, ToolchainBundle::AutoRegister::On); + toolchainsForBuildDevice, ToolchainBundle::HandleMissing::CreateAndRegister); for (const ToolchainBundle &b : bundlesForBuildDevice) rootItem()->appendChild(new ToolchainTreeItem(b)); rootItem()->appendChild(new ToolchainTreeItem); @@ -321,7 +321,7 @@ static void setToolchainsFromAbis(Kit *k, const LanguagesAndAbis &abisByLanguage // Get bundles. const QList bundles = ToolchainBundle::collectBundles( - ToolchainBundle::AutoRegister::On); + ToolchainBundle::HandleMissing::CreateAndRegister); // Set a matching bundle for each LanguageCategory/Abi pair, if possible. for (auto it = abisByCategory.cbegin(); it != abisByCategory.cend(); ++it) { diff --git a/src/plugins/projectexplorer/toolchainoptionspage.cpp b/src/plugins/projectexplorer/toolchainoptionspage.cpp index 1d017f0efbd..b44800a8ab9 100644 --- a/src/plugins/projectexplorer/toolchainoptionspage.cpp +++ b/src/plugins/projectexplorer/toolchainoptionspage.cpp @@ -267,7 +267,7 @@ public: m_container->setWidget(m_widgetStack); const QList bundles = ToolchainBundle::collectBundles( - ToolchainBundle::AutoRegister::On); + ToolchainBundle::HandleMissing::CreateAndRegister); for (const ToolchainBundle &b : bundles) insertBundle(b); @@ -400,8 +400,8 @@ void ToolChainOptionsWidget::handleToolchainsRegistered(const Toolchains &toolch return; } - const QList bundles - = ToolchainBundle::collectBundles(toolchains, ToolchainBundle::AutoRegister::On); + const QList bundles = ToolchainBundle::collectBundles( + toolchains, ToolchainBundle::HandleMissing::CreateAndRegister); for (const ToolchainBundle &bundle : bundles) insertBundle(bundle); updateState(); @@ -524,7 +524,7 @@ void ToolChainOptionsWidget::redetectToolchains() // Step 4: Create new bundles and add items for them. const QList newBundles - = ToolchainBundle::collectBundles(toAdd, ToolchainBundle::AutoRegister::Off); + = ToolchainBundle::collectBundles(toAdd, ToolchainBundle::HandleMissing::CreateOnly); for (const ToolchainBundle &bundle : newBundles) m_toAddList << insertBundle(bundle, true); } @@ -611,7 +611,7 @@ void ToolChainOptionsWidget::createToolchains(ToolchainFactory *factory, const Q toolchains << tc; } - const ToolchainBundle bundle(toolchains, ToolchainBundle::AutoRegister::Off); + const ToolchainBundle bundle(toolchains, ToolchainBundle::HandleMissing::CreateOnly); ExtendedToolchainTreeItem * const item = insertBundle(bundle, true); m_toAddList << item; m_toolChainView->setCurrentIndex(m_sortModel.mapFromSource(m_model.indexForItem(item))); diff --git a/src/plugins/qtsupport/qtkitaspect.cpp b/src/plugins/qtsupport/qtkitaspect.cpp index bc7be20b1d8..dbf648e392e 100644 --- a/src/plugins/qtsupport/qtkitaspect.cpp +++ b/src/plugins/qtsupport/qtkitaspect.cpp @@ -184,7 +184,7 @@ void QtKitAspectFactory::fix(Kit *k) return; QList bundles = ToolchainBundle::collectBundles( - ToolchainBundle::AutoRegister::On); + ToolchainBundle::HandleMissing::CreateAndRegister); using ProjectExplorer::Constants::CXX_LANGUAGE_ID; bundles = Utils::filtered(bundles, [version](const ToolchainBundle &b) { if (!b.isCompletelyValid() || !b.factory()->languageCategory().contains(CXX_LANGUAGE_ID))