Fix crash when trying to draw a schematic polygon with no segments.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18246
This commit is contained in:
Alex Shvartzkop 2024-06-23 07:02:43 +03:00
parent 0040c290ed
commit 69ee94f289
1 changed files with 13 additions and 8 deletions

View File

@ -1491,17 +1491,22 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer, bool aDimmed )
case SHAPE_T::POLY:
{
const std::vector<SHAPE*> polySegments = shape->MakeEffectiveShapes( true );
std::deque<VECTOR2D> pts;
for( SHAPE* polySegment : polySegments )
pts.push_back( static_cast<SHAPE_SEGMENT*>( polySegment )->GetSeg().A );
if( !polySegments.empty() )
{
std::deque<VECTOR2D> pts;
pts.push_back( static_cast<SHAPE_SEGMENT*>( polySegments.back() )->GetSeg().B );
for( SHAPE* polySegment : polySegments )
pts.push_back( static_cast<SHAPE_SEGMENT*>( polySegment )->GetSeg().A );
for( SHAPE* polySegment : polySegments )
delete polySegment;
pts.push_back(
static_cast<SHAPE_SEGMENT*>( polySegments.back() )->GetSeg().B );
m_gal->DrawPolygon( pts );
for( SHAPE* polySegment : polySegments )
delete polySegment;
m_gal->DrawPolygon( pts );
}
break;
}
@ -2675,7 +2680,7 @@ void SCH_PAINTER::draw( const SCH_SHEET* aSheet, int aLayer )
{
bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
bool DNP = aSheet->GetDNP();
bool markExclusion = eeconfig()->m_Appearance.mark_sim_exclusions
bool markExclusion = eeconfig()->m_Appearance.mark_sim_exclusions
&& aSheet->GetExcludedFromSim();
if( m_schSettings.IsPrinting() && drawingShadows )