From db97d77544fcd37b7fdc4f7f52fbc77f255fb803 Mon Sep 17 00:00:00 2001 From: John Beard Date: Fri, 8 Aug 2025 21:17:56 +0800 Subject: [PATCH] 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 --- common/project/net_settings.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/common/project/net_settings.cpp b/common/project/net_settings.cpp index 7ff0d8e237..4ad03ffb31 100644 --- a/common/project/net_settings.cpp +++ b/common/project/net_settings.cpp @@ -578,15 +578,12 @@ bool NET_SETTINGS::HasNetclassLabelAssignment( const wxString& netName ) const 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 ) { - if( assignment.first->GetPattern() == pattern ) - { - assignment.second = netclass; - ClearAllCaches(); + if( assignment.first->GetPattern() == pattern && assignment.second == netclass ) return; - } } // No assignment, add a new one