From a7a7e963c9543350a5b3ddc6c8f1c5fc500924ad Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Mon, 5 May 2025 13:52:02 -0400 Subject: [PATCH] bom export: don't break column order on mismatched column counts Fixes: https://gitlab.com/kicad/code/kicad/-/issues/20520 --- eeschema/fields_data_model.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/eeschema/fields_data_model.cpp b/eeschema/fields_data_model.cpp index d666479c7b..5a534f19ad 100644 --- a/eeschema/fields_data_model.cpp +++ b/eeschema/fields_data_model.cpp @@ -138,19 +138,20 @@ std::vector FIELDS_EDITOR_GRID_DATA_MODEL::GetFieldsOrdered() void FIELDS_EDITOR_GRID_DATA_MODEL::SetFieldsOrder( const std::vector& 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 ); + foundCount++; + break; } } }