From d7b2c81db593088df5a1c24a22aec8677e2d0d2f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 20 Dec 2023 13:06:32 +0000 Subject: [PATCH] Check added fields only if all fields were checked before. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16408 (cherry picked from commit 7e72a53876ac3dfa544623c60da26d77ba49fcb3) --- eeschema/dialogs/dialog_change_symbols.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index b87a9c848e..ed649bd965 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -350,14 +350,26 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList() } // Update the listbox widget + wxArrayInt checkedItems; + wxArrayString checkedNames; + + m_fieldsBox->GetCheckedItems( checkedItems ); + + for( int i : checkedItems ) + checkedNames.push_back( m_fieldsBox->GetString( i ) ); + + bool allChecked = checkedItems.size() == m_fieldsBox->GetCount(); + for( unsigned i = m_fieldsBox->GetCount() - 1; i >= MANDATORY_FIELDS; --i ) m_fieldsBox->Delete( i ); for( const wxString& fieldName : fieldNames ) + { m_fieldsBox->Append( fieldName ); - for( unsigned i = MANDATORY_FIELDS; i < m_fieldsBox->GetCount(); ++i ) - m_fieldsBox->Check( i, true ); + if( allChecked || alg::contains( checkedNames, fieldName ) ) + m_fieldsBox->Check( m_fieldsBox->GetCount() - 1, true ); + } }