bom export: don't break column order on mismatched column counts

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/20520
This commit is contained in:
Mike Williams 2025-05-05 13:52:02 -04:00
parent 00e9d0241c
commit 774cf6fbc8

View File

@ -138,19 +138,20 @@ std::vector<BOM_FIELD> FIELDS_EDITOR_GRID_DATA_MODEL::GetFieldsOrdered()
void FIELDS_EDITOR_GRID_DATA_MODEL::SetFieldsOrder( const std::vector<wxString>& aNewOrder ) void FIELDS_EDITOR_GRID_DATA_MODEL::SetFieldsOrder( const std::vector<wxString>& aNewOrder )
{ {
if( aNewOrder.size() == m_cols.size() )
{
size_t foundCount = 0; size_t foundCount = 0;
for( const wxString& newField : aNewOrder ) for( const wxString& newField : aNewOrder )
{ {
for( DATA_MODEL_COL& col : m_cols) if( foundCount >= m_cols.size() )
break;
for( DATA_MODEL_COL& col : m_cols )
{ {
if( col.m_fieldName == newField ) if( col.m_fieldName == newField )
{ {
std::swap( m_cols[foundCount], col ); std::swap( m_cols[foundCount], col );
foundCount++; foundCount++;
} break;
} }
} }
} }