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 46e6eb163b
commit a7a7e963c9

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 )
{
if( foundCount >= m_cols.size() )
break;
for( DATA_MODEL_COL& col : m_cols )
{ {
for( DATA_MODEL_COL& col : m_cols) if( col.m_fieldName == newField )
{ {
if( col.m_fieldName == newField ) std::swap( m_cols[foundCount], col );
{ foundCount++;
std::swap( m_cols[foundCount], col ); break;
foundCount++;
}
} }
} }
} }