From b681af4556411b8af4d951c04410b2fcba131654 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 2 Jun 2020 21:42:17 +0100 Subject: [PATCH] Check for duplicate field names. Fixes https://gitlab.com/kicad/code/kicad/issues/4219 (cherry picked from commit 5d493abea70c428b9b32dda562a205bdeed07157) --- .../dialogs/dialog_edit_component_in_lib.cpp | 19 +++++++++++++++++++ .../dialog_edit_component_in_schematic.cpp | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/eeschema/dialogs/dialog_edit_component_in_lib.cpp b/eeschema/dialogs/dialog_edit_component_in_lib.cpp index 4f4a708268..d7bf9f3a20 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib.cpp @@ -393,6 +393,25 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnGridCellChanging( wxGridEvent& event ) m_delayedFocusColumn = event.GetCol(); m_delayedFocusPage = 0; } + else if( event.GetCol() == FDC_NAME ) + { + wxString newName = event.GetString(); + + for( int i = 0; i < m_grid->GetNumberRows(); ++i ) + { + if( i == event.GetRow() ) + continue; + + if( newName.CmpNoCase( m_grid->GetCellValue( i, FDC_NAME ) ) == 0 ) + { + DisplayError( this, wxString::Format( _( "The name '%s' is already in use." ), + newName ) ); + event.Veto(); + m_delayedFocusRow = event.GetRow(); + m_delayedFocusColumn = event.GetCol(); + } + } + } else if( event.GetRow() == VALUE && event.GetCol() == FDC_VALUE ) m_SymbolNameCtrl->ChangeValue( event.GetString() ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index ac4a727530..79ec71ed2b 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -526,6 +526,25 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging( wxGridEvent& event m_delayedFocusRow = event.GetRow(); m_delayedFocusColumn = event.GetCol(); } + else if( event.GetCol() == FDC_NAME ) + { + wxString newName = event.GetString(); + + for( int i = 0; i < m_grid->GetNumberRows(); ++i ) + { + if( i == event.GetRow() ) + continue; + + if( newName.CmpNoCase( m_grid->GetCellValue( i, FDC_NAME ) ) == 0 ) + { + DisplayError( this, wxString::Format( _( "The name '%s' is already in use." ), + newName ) ); + event.Veto(); + m_delayedFocusRow = event.GetRow(); + m_delayedFocusColumn = event.GetCol(); + } + } + } editor->DecRef(); }