Browse Source

Maintain units even when opening standalone

The unit data is maintained in the instances so we need a temporary
instance setting if we do not have the parent sheet

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19361

(cherry picked from commit 39ed3c538f)
9.0
Seth Hillbrand 1 week ago
parent
commit
2116e272b5
  1. 18
      eeschema/sch_reference_list.cpp

18
eeschema/sch_reference_list.cpp

@ -803,6 +803,24 @@ SCH_REFERENCE::SCH_REFERENCE( SCH_SYMBOL* aSymbol, const SCH_SHEET_PATH& aSheetP
wxASSERT( aSymbol != nullptr );
m_rootSymbol = aSymbol;
// Ensure the symbol has instance data for the current sheet path so that the unit selection
// remains consistent even when loading a sheet without symbol instance records (for example
// when editing a subsheet directly).
SCH_SYMBOL_INSTANCE instance;
if( !aSymbol->GetInstance( instance, aSheetPath.Path(), false ) )
{
instance.m_Path = aSheetPath.Path();
instance.m_Reference = aSymbol->GetRef( &aSheetPath, false );
if( instance.m_Reference.IsEmpty() )
instance.m_Reference = aSymbol->GetField( FIELD_T::REFERENCE )->GetText();
instance.m_Unit = aSymbol->GetUnit();
aSymbol->AddHierarchicalReference( instance );
}
m_unit = aSymbol->GetUnitSelection( &aSheetPath );
m_footprint = aSymbol->GetFootprintFieldText( true, &aSheetPath, false );
m_sheetPath = aSheetPath;

Loading…
Cancel
Save