From 49d242944dee651a05c393a15ef1e214599d3df5 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 18 Jul 2020 10:58:10 +0100 Subject: [PATCH] Don't treat new netclass as changing a netclass name. In particular, since it goes from empty string to non-empty, the oldName comparison will cause it to pick up all unassigned nets. Fixes https://gitlab.com/kicad/code/kicad/issues/4922 --- common/dialogs/panel_setup_netclasses.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/common/dialogs/panel_setup_netclasses.cpp b/common/dialogs/panel_setup_netclasses.cpp index c4efe2e3f3..7f098a50b3 100644 --- a/common/dialogs/panel_setup_netclasses.cpp +++ b/common/dialogs/panel_setup_netclasses.cpp @@ -309,6 +309,7 @@ void PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns() for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ ) { wxString netclassName = m_netclassGrid->GetCellValue( ii, GRID_NAME ); + if( !netclassName.IsEmpty() ) netclassNames.push_back( netclassName ); } @@ -421,16 +422,21 @@ void PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging( wxGridEvent& event ) wxString oldName = m_netclassGrid->GetCellValue( event.GetRow(), GRID_NAME ); wxString newName = event.GetString(); - for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row ) + if( !oldName.IsEmpty() ) { - if( m_membershipGrid->GetCellValue( row, 1 ) == oldName ) - m_membershipGrid->SetCellValue( row, 1, newName ); + for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row ) + { + if( m_membershipGrid->GetCellValue( row, 1 ) == oldName ) + m_membershipGrid->SetCellValue( row, 1, newName ); + } } m_netclassesDirty = true; } else + { event.Veto(); + } } }