From 903c743a60dc7c327576be19e1f53afed3b87e93 Mon Sep 17 00:00:00 2001 From: JamesJCode <13408010-JamesJCode@users.noreply.gitlab.com> Date: Thu, 26 Sep 2024 18:58:44 +0100 Subject: [PATCH] Fix deep cloning and RunOnDescendants for groups containing generators Fixes https://gitlab.com/kicad/code/kicad/-/issues/17710 --- pcbnew/pcb_group.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pcbnew/pcb_group.cpp b/pcbnew/pcb_group.cpp index c86fa386cb..a3d77a52bc 100644 --- a/pcbnew/pcb_group.cpp +++ b/pcbnew/pcb_group.cpp @@ -27,6 +27,7 @@ #include <board.h> #include <board_item.h> #include <footprint.h> +#include <pcb_generator.h> #include <pcb_group.h> #include <confirm.h> #include <widgets/msgpanel.h> @@ -210,6 +211,8 @@ PCB_GROUP* PCB_GROUP::DeepClone() const { if( member->Type() == PCB_GROUP_T ) newGroup->AddItem( static_cast<PCB_GROUP*>( member )->DeepClone() ); + else if( member->Type() == PCB_GENERATOR_T ) + newGroup->AddItem( static_cast<PCB_GENERATOR*>( member )->DeepClone() ); else newGroup->AddItem( static_cast<BOARD_ITEM*>( member->Clone() ) ); } @@ -415,7 +418,7 @@ void PCB_GROUP::RunOnDescendants( const std::function<void( BOARD_ITEM* )>& aFun { aFunction( item ); - if( item->Type() == PCB_GROUP_T ) + if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T ) item->RunOnDescendants( aFunction, aDepth + 1 ); } }