Netclass: allow multiple assignments with the same pattern

This isn't really a problem, and overwriting the entry allows
for silent data loss by making a new assignment with the
same pattern as an existing one.

The resolve netclasses are de-duplicated later, so it's even
OK if the whole assignment is duplicated (in theory), but
continue to clean these up.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/21316
This commit is contained in:
John Beard 2025-08-08 21:17:56 +08:00
parent 88c09517f2
commit db97d77544

View File

@ -578,15 +578,12 @@ bool NET_SETTINGS::HasNetclassLabelAssignment( const wxString& netName ) const
void NET_SETTINGS::SetNetclassPatternAssignment( const wxString& pattern, const wxString& netclass ) void NET_SETTINGS::SetNetclassPatternAssignment( const wxString& pattern, const wxString& netclass )
{ {
// Replace existing assignment if we have one // Avoid exact duplicates - these shouldn't cause problems, due to later de-duplication
// but they are unnecessary.
for( auto& assignment : m_netClassPatternAssignments ) for( auto& assignment : m_netClassPatternAssignments )
{ {
if( assignment.first->GetPattern() == pattern ) if( assignment.first->GetPattern() == pattern && assignment.second == netclass )
{
assignment.second = netclass;
ClearAllCaches();
return; return;
}
} }
// No assignment, add a new one // No assignment, add a new one