From 7ee12d674ee80d09a4ad46e773873aeac4537f27 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 2 Apr 2019 07:08:10 -0700 Subject: [PATCH] pcbnew: Clear items before deleting vertex Reverting changes causes the item to become invalid. This can cause issues when we have dangling pointers for the VIEW routines left over. Until we implement a method of passing the reverted element back up to the calling routine, we need to remove the selection for each Revert() call. Fixes: lp:1821909 * https://bugs.launchpad.net/kicad/+bug/1821909 --- pcbnew/tools/point_editor.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index d50dd095aa..8f02f9d2fd 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -1165,18 +1165,24 @@ int POINT_EDITOR::removeCorner( const TOOL_EVENT& aEvent ) } setEditedPoint( nullptr ); - updatePoints(); if( valid ) + { commit.Push( _( "Remove a zone/polygon corner" ) ); + + // Refresh zone hatching + if( item->Type() == PCB_ZONE_AREA_T) + static_cast( item )->Hatch(); + + updatePoints(); + } else + { + m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); + getView()->Remove( m_editPoints.get() ); commit.Revert(); - - // Refresh zone hatching - if( item->Type() == PCB_ZONE_AREA_T) - static_cast( item )->Hatch(); - - updatePoints(); + m_editPoints.reset(); + } } return 0;