From 7a4650a1a9b03ea68d63de804a88dc2a3eb29921 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 16 Apr 2023 22:50:04 +0100 Subject: [PATCH] Double double-add items to the view. (cherry picked from commit a540c01c617f53d67380545f0946b1d0b58ec969) --- eeschema/sch_view.cpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index 361344b8d1..6f4f82d0a6 100644 --- a/eeschema/sch_view.cpp +++ b/eeschema/sch_view.cpp @@ -137,29 +137,25 @@ void SCH_VIEW::DisplaySymbol( LIB_SYMBOL* aSymbol ) if( !aSymbol ) return; - std::shared_ptr< LIB_SYMBOL > parent; - LIB_SYMBOL* drawnSymbol = aSymbol; - - // Draw the mandatory fields for aliases and parent symbols. + // Draw the fields. for( LIB_ITEM& item : aSymbol->GetDrawItems() ) { - if( item.Type() != LIB_FIELD_T ) - continue; + if( item.Type() == LIB_FIELD_T ) + { + LIB_FIELD* field = static_cast< LIB_FIELD* >( &item ); - LIB_FIELD* field = static_cast< LIB_FIELD* >( &item ); + wxCHECK2( field, continue ); - wxCHECK2( field, continue ); - - if( field->GetText().IsEmpty() ) - continue; - - Add( &item ); + Add( &item ); + } } + LIB_SYMBOL* drawnSymbol = aSymbol; + // Draw the parent items if the symbol is inherited from another symbol. if( aSymbol->IsAlias() ) { - parent = aSymbol->GetParent().lock(); + std::shared_ptr< LIB_SYMBOL > parent = aSymbol->GetParent().lock(); wxCHECK( parent, /* void */ ); @@ -168,9 +164,9 @@ void SCH_VIEW::DisplaySymbol( LIB_SYMBOL* aSymbol ) for( LIB_ITEM& item : drawnSymbol->GetDrawItems() ) { - // Don't show parent symbol fields. Users may be confused by shown fields that can not - // be edited. - if( aSymbol->IsAlias() && item.Type() == LIB_FIELD_T ) + // Fields already drawn above. (Besides, we don't want to show parent symbol fields as + // users may be confused by shown fields that can not be edited.) + if( item.Type() == LIB_FIELD_T ) continue; Add( &item );