Fix group ownership issue.

This commit is contained in:
Jeff Young 2025-04-29 18:10:31 +01:00
parent c528f3c605
commit fc969ae501

View File

@ -268,19 +268,24 @@ void PCB_GROUP::swapData( BOARD_ITEM* aImage )
std::swap( *this, *image );
RunOnChildren(
[&]( BOARD_ITEM* child )
{
child->SetParentGroup( this );
},
RECURSE_MODE::NO_RECURSE );
// A group doesn't own its children (they're owned by the board), so undo doesn't do a
// deep clone when making an image. However, it's still safest to update the parentGroup
// pointers of the group's children -- we just have to be careful to do it in the right
// order in case any of the children are shared (ie: image first, "this" second so that
// any shared children end up with "this").
image->RunOnChildren(
[&]( BOARD_ITEM* child )
{
child->SetParentGroup( image );
},
RECURSE_MODE::NO_RECURSE );
RunOnChildren(
[&]( BOARD_ITEM* child )
{
child->SetParentGroup( this );
},
RECURSE_MODE::NO_RECURSE );
}