From 17dc324e85021145d2c004fbbbfef279006993ca Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 2 Mar 2022 15:55:50 -0800 Subject: [PATCH] Explicitly give unit values Removes the ability to hide symbol units in file formats. This was mostly the case for a while but there remained corner cases where we left a default/hidden option Fixes https://gitlab.com/kicad/code/kicad/issues/10888 (cherry picked from commit 8c36ba36536226d3d0e99f5ea4297a0777183517) --- eeschema/dialogs/dialog_lib_symbol_properties.cpp | 2 +- eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp | 10 ++++------ eeschema/sch_symbol.h | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.cpp b/eeschema/dialogs/dialog_lib_symbol_properties.cpp index a56a5c2d8d..f80b161d21 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -593,7 +593,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnEditSpiceModel( wxCommandEvent& event ) { #ifdef KICAD_SPICE int diff = m_fields->size(); - auto symbol = SCH_SYMBOL( *m_libEntry, m_libEntry->GetLibId(), nullptr ); + auto symbol = SCH_SYMBOL( *m_libEntry, m_libEntry->GetLibId(), nullptr, 0 ); DIALOG_SPICE_MODEL dialog( this, symbol, m_fields ); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index fc5d9630bd..60a2d676d2 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -1090,14 +1090,12 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPa m_out->Print( 0, ")" ); } - int unit = -1; + int unit = aSymbol->GetUnit(); - if( !( aSymbol->GetInstanceReferences().size() > 1 ) ) - unit = aSymbol->GetUnit(); - else if( aSheetPath != nullptr ) + if( ( aSymbol->GetInstanceReferences().size() > 1 ) && aSheetPath ) unit = aSymbol->GetUnitSelection( aSheetPath ); - if ( unit >= 0 ) - m_out->Print( 0, " (unit %d)", unit ); + + m_out->Print( 0, " (unit %d)", unit ); if( aSymbol->GetConvert() == LIB_ITEM::LIB_CONVERT::DEMORGAN ) m_out->Print( 0, " (convert %d)", aSymbol->GetConvert() ); diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 77348dc5bd..8e2a04e37d 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -92,7 +92,7 @@ public: * @param setNewItemFlag is used to set the symbol #IS_NEW and #IS_MOVING flags. */ SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId, const SCH_SHEET_PATH* aSheet, - int unit = 0, int convert = 0, const wxPoint& pos = wxPoint( 0, 0 ) ); + int unit, int convert = 0, const wxPoint& pos = wxPoint( 0, 0 ) ); SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet, const PICKED_SYMBOL& aSel, const wxPoint& pos = wxPoint( 0, 0 ) );