From e560de496c5ada92287e2dcf6d36e73ab016d91f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 19 Mar 2021 16:13:22 +0000 Subject: [PATCH] Intersheet refs don't go in the view themselves. (Their parents draw them.) Also simplifies a couple of loops by using OfType(). Fixes https://gitlab.com/kicad/code/kicad/issues/7805 --- eeschema/sch_edit_frame.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index ee35319041..99b30eff2d 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1343,17 +1343,14 @@ void SCH_EDIT_FRAME::RecomputeIntersheetRefs() bool show = Schematic().Settings().m_IntersheetRefsShow; /* Refresh all global labels */ - for( EDA_ITEM* item : GetScreen()->Items() ) + for( EDA_ITEM* item : GetScreen()->Items().OfType( SCH_GLOBAL_LABEL_T ) ) { - if( item->Type() == SCH_GLOBAL_LABEL_T ) - { - SCH_GLOBALLABEL* global = static_cast( item ); + SCH_GLOBALLABEL* global = static_cast( item ); - global->GetIntersheetRefs()->SetVisible( show ); + global->GetIntersheetRefs()->SetVisible( show ); - if( show ) - GetCanvas()->GetView()->Update( global ); - } + if( show ) + GetCanvas()->GetView()->Update( global ); } } @@ -1367,20 +1364,13 @@ void SCH_EDIT_FRAME::ShowAllIntersheetRefs( bool aShow ) for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() ) { - for( SCH_ITEM* item : screen->Items() ) + for( SCH_ITEM* item : screen->Items().OfType( SCH_GLOBAL_LABEL_T ) ) { - if( item->Type() == SCH_GLOBAL_LABEL_T ) - { - SCH_GLOBALLABEL* gLabel = (SCH_GLOBALLABEL*)( item ); - SCH_FIELD* intersheetRef = gLabel->GetIntersheetRefs(); + SCH_GLOBALLABEL* gLabel = (SCH_GLOBALLABEL*)( item ); + SCH_FIELD* intersheetRef = gLabel->GetIntersheetRefs(); - intersheetRef->SetVisible( aShow ); - - if( aShow ) - AddToScreen( intersheetRef, screen ); - else - RemoveFromScreen( intersheetRef, screen ); - } + intersheetRef->SetVisible( aShow ); + UpdateItem( intersheetRef, true ); } } }