Check a SHAPE_POLY_SET outline exists before attempting to get it by index

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17687
This commit is contained in:
JamesJ 2024-04-06 18:44:23 +01:00 committed by jean-pierre charras
parent 8b5c292397
commit 026685ee48
1 changed files with 14 additions and 2 deletions

View File

@ -62,14 +62,26 @@ int SHAPE::GetClearance( const SHAPE* aOther ) const
/// Triangles check three vertices each but for the outline, we only need one.
/// These are also fractured, so we don't need to worry about holes
if( Type() == SHAPE_TYPE::SH_POLY_SET )
a_shapes.push_back( &static_cast<const SHAPE_POLY_SET*>( this )->COutline( 0 ) );
{
const SHAPE_POLY_SET* polySet = static_cast<const SHAPE_POLY_SET*>( this );
if( polySet->OutlineCount() > 0 )
a_shapes.push_back( &polySet->COutline( 0 ) );
}
else
{
GetIndexableSubshapes( a_shapes );
}
if( aOther->Type() == SHAPE_TYPE::SH_POLY_SET )
b_shapes.push_back( &static_cast<const SHAPE_POLY_SET*>( aOther )->COutline( 0 ) );
{
const SHAPE_POLY_SET* polySet = static_cast<const SHAPE_POLY_SET*>( aOther );
if( polySet->OutlineCount() > 0 )
b_shapes.push_back( &polySet->COutline( 0 ) );
}
else
{
aOther->GetIndexableSubshapes( b_shapes );
}
if( GetIndexableSubshapeCount() == 0 )
a_shapes.push_back( this );