ProjectExplorer: Add some soft asserts in toolchain factory functions

These might help with diagnosing mysterious crashes observed on user
machines.

Task-number: QTCREATORBUG-32127
Change-Id: Ia41cb4bd1f68717cec255a131d02c3b86f87b769
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Christian Kandeler
2024-12-09 12:48:42 +01:00
parent 0cae52c16c
commit 746fd23e99

View File

@@ -187,7 +187,9 @@ QString Toolchain::detectionSource() const
ToolchainFactory *Toolchain::factory() const
{
return ToolchainFactory::factoryForType(typeId());
ToolchainFactory * const factory = ToolchainFactory::factoryForType(typeId());
QTC_ASSERT(factory, qDebug() << typeId());
return factory;
}
QByteArray Toolchain::id() const
@@ -741,12 +743,11 @@ void ToolchainFactory::autoDetectionToMap(Store &data, bool detected)
Toolchain *ToolchainFactory::createToolchain(Id toolchainType)
{
for (ToolchainFactory *factory : std::as_const(toolchainFactories())) {
if (factory->m_supportedToolchainType == toolchainType) {
if (Toolchain *tc = factory->create()) {
tc->d->m_typeId = toolchainType;
return tc;
}
if (ToolchainFactory * const factory = factoryForType(toolchainType)) {
if (Toolchain * const tc = factory->create()) {
QTC_ASSERT(tc->typeId() == toolchainType, qDebug() << toolchainType.toSetting());
tc->d->m_typeId = toolchainType; // FIXME: Redundant?
return tc;
}
}
return nullptr;