From 8c36ba36536226d3d0e99f5ea4297a0777183517 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 --- 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 5090ae381b..7e8c4fa4b5 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -591,7 +591,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 13d798c2a3..cebdb1007e 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -685,14 +685,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 248d2b5ed7..97c3f400ef 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 VECTOR2I& pos = VECTOR2I( 0, 0 ) ); + int unit, int convert = 0, const VECTOR2I& pos = VECTOR2I( 0, 0 ) ); SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet, const PICKED_SYMBOL& aSel, const VECTOR2I& pos = VECTOR2I( 0, 0 ) );