From 04f61fb1f2d88339f02fd19ded011ed31dfbc8ca Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 13 Oct 2020 17:54:01 +0100 Subject: [PATCH] Rebuild groups as a separate pass (required for nested groups). Fixes https://gitlab.com/kicad/code/kicad/issues/5858 --- pcbnew/class_module.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index c049776d85..32e97af585 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -128,12 +128,19 @@ MODULE::MODULE( const MODULE& aModule ) : for( PCB_GROUP* group : aModule.Groups() ) { PCB_GROUP* newGroup = static_cast( group->Clone() ); + ptrMap[ group ] = newGroup; + Add( newGroup ); + } + + // Rebuild groups + for( PCB_GROUP* group : aModule.Groups() ) + { + PCB_GROUP* newGroup = static_cast( ptrMap[ group ] ); + const_cast*>( &newGroup->GetItems() )->clear(); for( BOARD_ITEM* member : group->GetItems() ) newGroup->AddItem( ptrMap[ member ] ); - - Add( newGroup ); } // Copy auxiliary data: 3D_Drawings info