diff --git a/eeschema/dialogs/dialog_edit_component_in_lib.cpp b/eeschema/dialogs/dialog_edit_component_in_lib.cpp index f5b7a02078..a1de975fcf 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib.cpp @@ -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() ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 0511c5df1b..e53e58a9d2 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -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(); }