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;