From 4be56825bb669f0b16ddf93c8503a461abddd7ac Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 4 Jan 2022 21:28:04 -0500 Subject: [PATCH] Fix creating polygons from footprint rule areas Fixes https://gitlab.com/kicad/code/kicad/-/issues/10257 (cherry picked from commit e9b91b6fab1d0e84c371c2eb3e0a585b0a5625eb) --- pcbnew/board_commit.cpp | 5 +++++ pcbnew/tools/convert_tool.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index 2296c5ef55..a75dd1766e 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -122,12 +122,17 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a int changeFlags = ent.m_type & CHT_FLAGS; BOARD_ITEM* boardItem = static_cast( ent.m_item ); + wxASSERT( ent.m_item ); + // Module items need to be saved in the undo buffer before modification if( m_isFootprintEditor ) { // Be sure that we are storing a footprint if( ent.m_item->Type() != PCB_FOOTPRINT_T ) + { ent.m_item = ent.m_item->GetParent(); + wxASSERT( ent.m_item ); + } // We have not saved the footprint yet, so let's create an entry if( savedModules.count( ent.m_item ) == 0 ) diff --git a/pcbnew/tools/convert_tool.cpp b/pcbnew/tools/convert_tool.cpp index 28c3c499be..117febb301 100644 --- a/pcbnew/tools/convert_tool.cpp +++ b/pcbnew/tools/convert_tool.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -183,6 +184,10 @@ int CONVERT_TOOL::CreatePolys( const TOOL_EVENT& aEvent ) if( FP_SHAPE* graphic = dynamic_cast( selection.Front() ) ) parentFootprint = graphic->GetParentFootprint(); + else if( FP_ZONE* zone = dynamic_cast( selection.Front() ) ) + parentFootprint = static_cast( zone->GetParent() ); + else + wxFAIL_MSG( "Unimplemented footprint parent in CONVERT_TOOL::CreatePolys" ); BOARD_COMMIT commit( m_frame );