From 31cc1006698b055913cb005bfe7fcdf9d602e8aa Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 25 Oct 2020 15:01:55 +0000 Subject: [PATCH] Don't make clients deal with nested SHAPE_COMPOUNDs. --- libs/kimath/include/geometry/shape_compound.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/kimath/include/geometry/shape_compound.h b/libs/kimath/include/geometry/shape_compound.h index 144b3fd6ba..e8b8adfb58 100644 --- a/libs/kimath/include/geometry/shape_compound.h +++ b/libs/kimath/include/geometry/shape_compound.h @@ -75,7 +75,20 @@ public: void AddShape( SHAPE* aShape ) { - m_shapes.push_back( aShape ); + // Don't make clients deal with nested SHAPE_COMPOUNDs + if( aShape->HasIndexableSubshapes() ) + { + std::vector subshapes; + aShape->GetIndexableSubshapes( subshapes ); + + for( SHAPE* subshape : subshapes ) + m_shapes.push_back( subshape ); + } + else + { + m_shapes.push_back( aShape ); + } + m_dirty = true; }