Annotation: fix wrong multi-unit annotation messages

SCH_SYMBOL::Unit() is updated when the symbol is on the screen, we need
to get the instance unit so it's right even if it's not being displayed /
has never been displayed.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/12050
This commit is contained in:
Mike Williams 2022-07-21 10:48:47 -04:00
parent d9449b9beb
commit c3d952644c
1 changed files with 3 additions and 1 deletions

View File

@ -488,12 +488,14 @@ const wxString SCH_SYMBOL::GetRef( const SCH_SHEET_PATH* sheet, bool aIncludeUni
{ {
KIID_PATH path = sheet->Path(); KIID_PATH path = sheet->Path();
wxString ref; wxString ref;
wxString subRef;
for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences ) for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
{ {
if( instance.m_Path == path ) if( instance.m_Path == path )
{ {
ref = instance.m_Reference; ref = instance.m_Reference;
subRef = LIB_SYMBOL::SubReference( instance.m_Unit );
break; break;
} }
} }
@ -512,7 +514,7 @@ const wxString SCH_SYMBOL::GetRef( const SCH_SHEET_PATH* sheet, bool aIncludeUni
ref = UTIL::GetRefDesUnannotated( m_prefix ); ref = UTIL::GetRefDesUnannotated( m_prefix );
if( aIncludeUnit && GetUnitCount() > 1 ) if( aIncludeUnit && GetUnitCount() > 1 )
ref += LIB_SYMBOL::SubReference( GetUnit() ); ref += subRef;
return ref; return ref;
} }