From 2bf51950e4ef76b647a596a5ded70c8e1a191156 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 15 Mar 2026 14:43:45 +0100 Subject: [PATCH] cafCmdFeatureManager: log and stop with clear message for unknown command feature Use CAF_PDM_LOG_ERROR and qFatal to notify the developer with an actionable message when a command feature ID is not registered in the factory. This replaces the silent CAF_ASSERT and makes it clear that the feature may have been deleted without removing all references in appendMenuItems(). --- Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp b/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp index 29ae651eb3..8560bde4ef 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp @@ -39,6 +39,7 @@ #include "cafCmdFeature.h" #include "cafCmdSelectionHelper.h" #include "cafFactory.h" +#include "cafPdmLogging.h" #include #include @@ -150,7 +151,15 @@ std::pair CmdFeatureManager::createFeature( const std::stri } CmdFeature* feature = CommandFeatureFactory::instance()->create( commandId ); - CAF_ASSERT( feature ); // The command ID is not known in the factory + if ( !feature ) + { + const QString message = + QString( "Command feature '%1' is not registered. It may have been deleted without removing all " + "references in appendMenuItems()." ) + .arg( QString::fromStdString( commandId ) ); + CAF_PDM_LOG_ERROR( message ); + qFatal( "%s", message.toUtf8().constData() ); + } feature->setParent( this ); size_t index = m_commandFeatures.size();