Check for duplicate field names.

Fixes https://gitlab.com/kicad/code/kicad/issues/4219
This commit is contained in:
Jeff Young 2020-06-02 21:42:17 +01:00
parent c01046c12f
commit 5d493abea7
2 changed files with 38 additions and 0 deletions

View File

@ -369,6 +369,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() );

View File

@ -553,6 +553,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();
}