diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index c1481044ef..33d6598292 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -504,27 +504,27 @@ bool SCH_SYMBOL::IsReferenceStringValid( const wxString& aReferenceString ) void SCH_SYMBOL::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref ) { KIID_PATH path = sheet->Path(); - bool notInArray = true; + bool found = false; // check to see if it is already there before inserting it for( SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences ) { if( instance.m_Path == path ) { + found = true; instance.m_Reference = ref; - notInArray = false; + break; } } - if( notInArray ) + if( !found ) AddHierarchicalReference( path, ref, m_unit ); for( std::unique_ptr& pin : m_pins ) pin->ClearDefaultNetName( sheet ); - SCH_FIELD* rf = GetField( REFERENCE_FIELD ); - - rf->SetText( ref ); // for drawing. + if( Schematic() && *sheet == Schematic()->CurrentSheet() ) + m_fields[ REFERENCE_FIELD ].SetText( ref ); // Reinit the m_prefix member if needed m_prefix = UTIL::GetRefDesPrefix( ref ); @@ -634,20 +634,28 @@ void SCH_SYMBOL::SetValue( const SCH_SHEET_PATH* sheet, const wxString& aValue ) } KIID_PATH path = sheet->Path(); + bool found = false; // check to see if it is already there before inserting it for( SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences ) { if( instance.m_Path == path ) { + found = true; instance.m_Value = aValue; - return; + break; } } // didn't find it; better add it - AddHierarchicalReference( path, UTIL::GetRefDesUnannotated( m_prefix ), m_unit, - aValue, wxEmptyString ); + if( !found ) + { + AddHierarchicalReference( path, UTIL::GetRefDesUnannotated( m_prefix ), m_unit, aValue, + wxEmptyString ); + } + + if( Schematic() && *sheet == Schematic()->CurrentSheet() ) + m_fields[ VALUE_FIELD ].SetText( aValue ); } @@ -685,20 +693,28 @@ void SCH_SYMBOL::SetFootprint( const SCH_SHEET_PATH* sheet, const wxString& aFoo } KIID_PATH path = sheet->Path(); + bool found = false; // check to see if it is already there before inserting it for( SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences ) { if( instance.m_Path == path ) { + found = true; instance.m_Footprint = aFootprint; - return; + break; } } // didn't find it; better add it - AddHierarchicalReference( path, UTIL::GetRefDesUnannotated( m_prefix ), m_unit, - wxEmptyString, aFootprint ); + if( !found ) + { + AddHierarchicalReference( path, UTIL::GetRefDesUnannotated( m_prefix ), m_unit, + wxEmptyString, aFootprint ); + } + + if( Schematic() && *sheet == Schematic()->CurrentSheet() ) + m_fields[ FOOTPRINT_FIELD ].SetText( aFootprint ); } diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 7aefa235fa..0d91f9efcd 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -263,6 +263,7 @@ SYMBOL_EDIT_FRAME::~SYMBOL_EDIT_FRAME() delete screen; m_isSymbolFromSchematic = false; } + // current screen is destroyed in EDA_DRAW_FRAME SetScreen( m_dummyScreen );