sch groups: add swap data fix

Copied from 199a7a34ead5998cdd7269338312f34bc4022703 for board items
This commit is contained in:
Mike Williams 2025-04-21 15:02:35 -04:00
parent 9cb0d100e5
commit f51c5c396f

View File

@ -250,8 +250,23 @@ SCH_GROUP* SCH_GROUP::DeepDuplicate() const
void SCH_GROUP::swapData( SCH_ITEM* aImage ) void SCH_GROUP::swapData( SCH_ITEM* aImage )
{ {
assert( aImage->Type() == SCH_GROUP_T ); assert( aImage->Type() == SCH_GROUP_T );
SCH_GROUP* image = static_cast<SCH_GROUP*>( aImage );
std::swap( *( (SCH_GROUP*) this ), *( (SCH_GROUP*) aImage ) ); std::swap( *( (SCH_GROUP*) this ), *( (SCH_GROUP*) aImage ) );
RunOnChildren(
[&]( SCH_ITEM* child )
{
child->SetParentGroup( this );
},
RECURSE_MODE::NO_RECURSE );
image->RunOnChildren(
[&]( SCH_ITEM* child )
{
child->SetParentGroup( image );
},
RECURSE_MODE::NO_RECURSE );
} }