Don't consider a group to be on a copper layer.

Its members can be on copper layers, but the group itself isn't on any
layer.

Also fixes a bug where we were trying to clone TRIANGULATED_POLYGON::TRI
shapes as indexable sub-shapes.  (The TRI only has indexes into its
parent, so cloning it will only result in segfaults down the line.)

Also fixes a bug where we weren't including copper items inside groups
when checking footprint net ties.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15021
This commit is contained in:
Jeff Young 2023-06-20 18:12:55 +01:00
parent 21f2f98270
commit 40abb013ec
3 changed files with 19 additions and 3 deletions

View File

@ -124,6 +124,12 @@ public:
wxFAIL_MSG( wxT( "groups don't support layer SetLayer" ) ); wxFAIL_MSG( wxT( "groups don't support layer SetLayer" ) );
} }
bool IsOnCopperLayer() const override
{
// A group might have members on a copper layer, but isn't itself on any layer.
return false;
}
/** Set layer for all items within the group. /** Set layer for all items within the group.
* *
* To avoid freezes with circular references, the maximum depth is 20 by default. * To avoid freezes with circular references, the maximum depth is 20 by default.

View File

@ -81,7 +81,7 @@ public:
void AddShape( SHAPE* aShape ) void AddShape( SHAPE* aShape )
{ {
// Don't make clients deal with nested SHAPE_COMPOUNDs // Don't make clients deal with nested SHAPE_COMPOUNDs
if( aShape->HasIndexableSubshapes() ) if( dynamic_cast<SHAPE_COMPOUND*>( aShape ) )
{ {
std::vector<const SHAPE*> subshapes; std::vector<const SHAPE*> subshapes;
aShape->GetIndexableSubshapes( subshapes ); aShape->GetIndexableSubshapes( subshapes );
@ -102,7 +102,7 @@ public:
void AddShape( std::shared_ptr<SHAPE> aShape ) void AddShape( std::shared_ptr<SHAPE> aShape )
{ {
// Don't make clients deal with nested SHAPE_COMPOUNDs // Don't make clients deal with nested SHAPE_COMPOUNDs
if( aShape->HasIndexableSubshapes() ) if( dynamic_cast<SHAPE_COMPOUND*>( aShape.get() ) )
{ {
std::vector<const SHAPE*> subshapes; std::vector<const SHAPE*> subshapes;
aShape->GetIndexableSubshapes( subshapes ); aShape->GetIndexableSubshapes( subshapes );
@ -125,7 +125,7 @@ public:
int Size() const int Size() const
{ {
return m_shapes.size(); return (int) m_shapes.size();
} }
void Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override; void Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override;

View File

@ -2417,7 +2417,17 @@ void FOOTPRINT::CheckNetTies( const std::function<void( const BOARD_ITEM* aItem,
for( BOARD_ITEM* item : m_drawings ) for( BOARD_ITEM* item : m_drawings )
{ {
if( item->IsOnCopperLayer() ) if( item->IsOnCopperLayer() )
{
copperItems.push_back( item ); copperItems.push_back( item );
}
else if( PCB_GROUP* group = dynamic_cast<PCB_GROUP*>( item ) )
{
group->RunOnDescendants( [&]( BOARD_ITEM* descendent )
{
if( descendent->IsOnCopperLayer() )
copperItems.push_back( descendent );
} );
}
} }
for( ZONE* zone : m_zones ) for( ZONE* zone : m_zones )