Eeschema: ensure reference field is initialized when adding a new symbol in schematic

This commit is contained in:
jean-pierre charras 2022-08-24 14:30:14 +02:00
parent 4d9802760e
commit 9af666ba34
1 changed files with 2 additions and 1 deletions

View File

@ -524,7 +524,8 @@ void SCH_SYMBOL::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref )
for( std::unique_ptr<SCH_PIN>& pin : m_pins )
pin->ClearDefaultNetName( sheet );
if( Schematic() && *sheet == Schematic()->CurrentSheet() )
// Schematic() is null for new components just added
if( !Schematic() || *sheet == Schematic()->CurrentSheet() )
m_fields[ REFERENCE_FIELD ].SetText( ref );
// Reinit the m_prefix member if needed