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 );
if( !polySegments.empty() )
{
std::deque<VECTOR2D> pts;
for( SHAPE* polySegment : polySegments )
pts.push_back( static_cast<SHAPE_SEGMENT*>( polySegment )->GetSeg().A );
pts.push_back( static_cast<SHAPE_SEGMENT*>( polySegments.back() )->GetSeg().B );
pts.push_back(
static_cast<SHAPE_SEGMENT*>( polySegments.back() )->GetSeg().B );
for( SHAPE* polySegment : polySegments )
delete polySegment;
m_gal->DrawPolygon( pts );
}
break;
}