From 6ac64d290b8caa382995b5e29dbb175d8de014bd Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 10 Mar 2025 13:31:38 +0000 Subject: [PATCH] Check parent footprint as well for component class. Also output more descriptive text when checking inherited rules on parent footprint. Fixes https://gitlab.com/kicad/code/kicad/-/issues/20281 --- pcbnew/drc/drc_engine.cpp | 12 ++++++++---- pcbnew/pcbexpr_functions.cpp | 7 ++++++- pcbnew/tools/board_inspection_tool.cpp | 3 ++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index 27dcf36dda..35bc60db92 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -1349,8 +1349,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO { std::vector* ruleset = m_constraintMap[ aConstraintType ]; - for( int ii = 0; ii < (int) ruleset->size(); ++ii ) - processConstraint( ruleset->at( ii ) ); + for( DRC_ENGINE_CONSTRAINT* rule : *ruleset ) + processConstraint( rule ); } if( constraint.GetParentRule() && !constraint.GetParentRule()->m_Implicit ) @@ -1364,6 +1364,10 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO || aConstraintType == THERMAL_RELIEF_GAP_CONSTRAINT || aConstraintType == THERMAL_SPOKE_WIDTH_CONSTRAINT ) ) { + REPORT( "" ) + REPORT( wxString::Format( _( "Inheriting from parent: %s." ), + EscapeHTML( parentFootprint->GetItemDescription( this, true ) ) ) ) + if( a == pad ) a = parentFootprint; else @@ -1373,8 +1377,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO { std::vector* ruleset = m_constraintMap[ aConstraintType ]; - for( int ii = 0; ii < (int) ruleset->size(); ++ii ) - processConstraint( ruleset->at( ii ) ); + for( DRC_ENGINE_CONSTRAINT* rule : *ruleset ) + processConstraint( rule ); if( constraint.GetParentRule() && !constraint.GetParentRule()->m_Implicit ) return constraint; diff --git a/pcbnew/pcbexpr_functions.cpp b/pcbnew/pcbexpr_functions.cpp index ddfede3fdf..8ef7f64280 100644 --- a/pcbnew/pcbexpr_functions.cpp +++ b/pcbnew/pcbexpr_functions.cpp @@ -1263,7 +1263,12 @@ static void hasComponentClassFunc( LIBEVAL::CONTEXT* aCtx, void* self ) result->SetDeferredEval( [item, arg]() -> double { - FOOTPRINT* footprint = dynamic_cast( item ); + FOOTPRINT* footprint = nullptr; + + if( item->Type() == PCB_FOOTPRINT_T ) + footprint = static_cast( item ); + else + footprint = item->GetParentFootprint(); if( !footprint ) return 0.0; diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index 0e4032b71c..03a7a51cac 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -302,7 +302,8 @@ wxString BOARD_INSPECTION_TOOL::InspectDRCErrorMenuText( const std::shared_ptrGetErrorCode() == DRCE_CLEARANCE || aDRCItem->GetErrorCode() == DRCE_EDGE_CLEARANCE || aDRCItem->GetErrorCode() == DRCE_HOLE_CLEARANCE - || aDRCItem->GetErrorCode() == DRCE_DRILLED_HOLES_TOO_CLOSE ) + || aDRCItem->GetErrorCode() == DRCE_DRILLED_HOLES_TOO_CLOSE + || aDRCItem->GetErrorCode() == DRCE_STARVED_THERMAL ) { return menuDescription( PCB_ACTIONS::inspectClearance ); }