From 003acbd686d213600aa5f94b92cf917c9630b8b2 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 2 Oct 2023 15:38:22 +0100 Subject: [PATCH] Clear render caches before plotting. Also fixes a bug where text variables in LIB_TEXT weren't getting expanded when plotting. Fixes https://gitlab.com/kicad/code/kicad/-/issues/15765 --- eeschema/sch_screen.cpp | 5 +++++ eeschema/sch_symbol.cpp | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index c32f89f4de..c1ea502c2a 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -1168,12 +1168,14 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter ) const item->Plot( aPlotter, background ); } + // Plot the background items for( const SCH_ITEM* item : other ) { aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); item->Plot( aPlotter, background ); } + // Plot the foreground items for( const SCH_ITEM* item : other ) { aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); @@ -1187,7 +1189,10 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter ) const aPlotter->SetCurrentLineWidth( std::max( sym->GetPenWidth(), defaultPenWidth ) ); for( SCH_FIELD field : sym->GetFields() ) + { + field.ClearRenderCache(); field.Plot( aPlotter, false ); + } sym->PlotPins( aPlotter ); diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index a043204d4d..c7291dd5b8 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -2332,6 +2332,17 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground ) const tempPin->SetFlags( IS_DANGLING ); } + for( LIB_ITEM& item : tempSymbol.GetDrawItems() ) + { + if( EDA_TEXT* text = dynamic_cast( &item ) ) + { + // Use SCH_FIELD's text resolver + SCH_FIELD dummy( (SCH_ITEM*) this, -1 ); + dummy.SetText( text->GetText() ); + text->SetText( dummy.GetShownText( false ) ); + } + } + TRANSFORM temp = GetTransform(); aPlotter->StartBlock( nullptr ); @@ -2340,8 +2351,11 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground ) const tempSymbol.Plot( aPlotter, GetUnit(), GetConvert(), local_background, m_pos, temp, GetDNP() ); - for( const SCH_FIELD& field : m_fields ) + for( SCH_FIELD field : m_fields ) + { + field.ClearRenderCache(); field.Plot( aPlotter, local_background ); + } } if( m_DNP )