Fix zone merge intersection algorithm.

Fixes https://gitlab.com/kicad/code/kicad/issues/11492

(cherry picked from commit 5f10c15a87)
This commit is contained in:
Jeff Young 2022-04-29 18:29:28 +01:00
parent a2e9c0ea73
commit aac4f30b7d
1 changed files with 19 additions and 5 deletions

View File

@ -1458,7 +1458,18 @@ int BOARD_EDITOR_CONTROL::ZoneMerge( const TOOL_EVENT& aEvent )
continue;
}
if( !board->TestZoneIntersection( curr_area, firstZone ) )
bool intersects = curr_area == firstZone;
for( ZONE* candidate : toMerge )
{
if( intersects )
break;
if( board->TestZoneIntersection( curr_area, candidate ) )
intersects = true;
}
if( !intersects )
{
wxLogMessage( _( "Some zones did not intersect and were not merged." ) );
continue;
@ -1469,12 +1480,15 @@ int BOARD_EDITOR_CONTROL::ZoneMerge( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
if( mergeZones( m_frame, commit, toMerge, merged ) )
if( !toMerge.empty() )
{
commit.Push( wxT( "Merge zones" ) );
if( mergeZones( m_frame, commit, toMerge, merged ) )
{
commit.Push( wxT( "Merge zones" ) );
for( EDA_ITEM* item : merged )
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, item );
for( EDA_ITEM* item : merged )
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, item );
}
}
return 0;