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
This commit is contained in:
Seth Hillbrand 2019-04-02 07:08:10 -07:00
parent 88faac309f
commit 7ee12d674e
1 changed files with 13 additions and 7 deletions

View File

@ -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<ZONE_CONTAINER*>( 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<ZONE_CONTAINER*>( item )->Hatch();
updatePoints();
m_editPoints.reset();
}
}
return 0;