Don't attempt to rename field more than once.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18330
This commit is contained in:
Jeff Young 2024-07-07 11:55:04 +01:00
parent 1f18cc8e0e
commit e9d376c912

View File

@ -84,10 +84,13 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::RenameColumn( int aCol, const wxString& newN
{ {
SCH_SYMBOL* symbol = m_symbolsList[i].GetSymbol(); SCH_SYMBOL* symbol = m_symbolsList[i].GetSymbol();
auto node = m_dataStore[symbol->m_Uuid].extract( m_cols[aCol].m_fieldName ); // Careful; field may have already been renamed from another sheet instance
if( auto node = m_dataStore[symbol->m_Uuid].extract( m_cols[aCol].m_fieldName ) )
{
node.key() = newName; node.key() = newName;
m_dataStore[symbol->m_Uuid].insert( std::move( node ) ); m_dataStore[symbol->m_Uuid].insert( std::move( node ) );
} }
}
m_cols[aCol].m_fieldName = newName; m_cols[aCol].m_fieldName = newName;
m_cols[aCol].m_label = newName; m_cols[aCol].m_label = newName;