Set new zone priority to unique number

Previously new zones' priorities were all set to 0.  This is almost
always wrong and can lead to unintended conflicts.  The new zone default
value is now set to one higher than the largest number on the board.
This is a better default value because it will not conflict with
existing values.
This commit is contained in:
Seth Hillbrand 2022-08-24 16:34:53 -07:00
parent 2a9b76c5ff
commit 3e4cfab254
2 changed files with 12 additions and 1 deletions

View File

@ -68,6 +68,17 @@ std::unique_ptr<ZONE> ZONE_CREATE_HELPER::createNewZone( bool aKeepout )
zoneInfo.m_NetcodeSelection = highlightedNets.empty() ? -1 : *highlightedNets.begin();
zoneInfo.SetIsRuleArea( m_params.m_keepout );
// By default, new zones should have the highest available priority
if( m_params.m_mode != ZONE_MODE::GRAPHIC_POLYGON
&& ( zoneInfo.m_Layers & LSET::AllCuMask() ).any() )
{
unsigned priority = 0;
for( ZONE* zone : board->Zones() )
priority = std::max( priority, zone->GetAssignedPriority() );
zoneInfo.m_ZonePriority = static_cast<int>( priority + 1 );
}
// If we don't have a net from highlighting, maybe we can get one from the selection
PCB_SELECTION_TOOL* selectionTool = m_tool.GetManager()->GetTool<PCB_SELECTION_TOOL>();

View File

@ -78,7 +78,7 @@ public:
SMOOTHING_LAST // sentinel
};
int m_ZonePriority; // Priority (0 ... N) of the zone
unsigned m_ZonePriority; // Priority (0 ... N) of the zone
ZONE_FILL_MODE m_FillMode;
int m_ZoneClearance; // Minimal clearance value