Check for duplicate field names.

Fixes https://gitlab.com/kicad/code/kicad/issues/4219

(cherry picked from commit 5d493abea7)
This commit is contained in:
Jeff Young 2020-06-02 21:42:17 +01:00
parent 78d66a9ac3
commit b681af4556
2 changed files with 38 additions and 0 deletions

View File

@ -393,6 +393,25 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnGridCellChanging( wxGridEvent& event )
m_delayedFocusColumn = event.GetCol(); m_delayedFocusColumn = event.GetCol();
m_delayedFocusPage = 0; 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 ) else if( event.GetRow() == VALUE && event.GetCol() == FDC_VALUE )
m_SymbolNameCtrl->ChangeValue( event.GetString() ); m_SymbolNameCtrl->ChangeValue( event.GetString() );

View File

@ -526,6 +526,25 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging( wxGridEvent& event
m_delayedFocusRow = event.GetRow(); m_delayedFocusRow = event.GetRow();
m_delayedFocusColumn = event.GetCol(); 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(); editor->DecRef();
} }