From 75daa1afec96ef96f330b038d288be32ec7cf87c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 26 Aug 2023 16:12:12 +0100 Subject: [PATCH] Don't presume all cached glyphs are outline glyphs. Fixes https://gitlab.com/kicad/code/kicad/-/issues/15508 (cherry picked from commit 949458bbe127f3f3b8263b52dcd40fe264d2bd5f) --- eeschema/sch_field.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 9f2e808467..de51c0ea4f 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -92,8 +92,10 @@ SCH_FIELD::SCH_FIELD( const SCH_FIELD& aField ) : for( const std::unique_ptr& glyph : aField.m_renderCache ) { - KIFONT::OUTLINE_GLYPH* outline_glyph = static_cast( glyph.get() ); - m_renderCache.emplace_back( std::make_unique( *outline_glyph ) ); + if( KIFONT::OUTLINE_GLYPH* outline = dynamic_cast( glyph.get() ) ) + m_renderCache.emplace_back( std::make_unique( *outline ) ); + else if( KIFONT::STROKE_GLYPH* stroke = dynamic_cast( glyph.get() ) ) + m_renderCache.emplace_back( std::make_unique( *stroke ) ); } m_renderCacheValid = aField.m_renderCacheValid; @@ -116,8 +118,10 @@ SCH_FIELD& SCH_FIELD::operator=( const SCH_FIELD& aField ) for( const std::unique_ptr& glyph : aField.m_renderCache ) { - KIFONT::OUTLINE_GLYPH* outline_glyph = static_cast( glyph.get() ); - m_renderCache.emplace_back( std::make_unique( *outline_glyph ) ); + if( KIFONT::OUTLINE_GLYPH* outline = dynamic_cast( glyph.get() ) ) + m_renderCache.emplace_back( std::make_unique( *outline ) ); + else if( KIFONT::STROKE_GLYPH* stroke = dynamic_cast( glyph.get() ) ) + m_renderCache.emplace_back( std::make_unique( *stroke ) ); } m_renderCacheValid = aField.m_renderCacheValid;