diff --git a/libs/kimath/include/geometry/shape_compound.h b/libs/kimath/include/geometry/shape_compound.h index e8b8adfb58..294e7188e1 100644 --- a/libs/kimath/include/geometry/shape_compound.h +++ b/libs/kimath/include/geometry/shape_compound.h @@ -82,7 +82,9 @@ public: aShape->GetIndexableSubshapes( subshapes ); for( SHAPE* subshape : subshapes ) - m_shapes.push_back( subshape ); + m_shapes.push_back( subshape->Clone() ); + + delete aShape; } else { diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 26a25d5b60..5f4ffd3ccd 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -1680,12 +1680,12 @@ std::shared_ptr MODULE::GetEffectiveShape( PCB_LAYER_ID aLayer ) const // We'll go with (2) for now.... for( D_PAD* pad : Pads() ) - shape->AddShape( pad->GetEffectiveShape( aLayer ).get() ); + shape->AddShape( pad->GetEffectiveShape( aLayer )->Clone() ); for( BOARD_ITEM* item : GraphicalItems() ) { if( item->Type() == PCB_FP_SHAPE_T ) - shape->AddShape( item->GetEffectiveShape( aLayer ).get() ); + shape->AddShape( item->GetEffectiveShape( aLayer )->Clone() ); } return shape;