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,12 +1165,10 @@ int POINT_EDITOR::removeCorner( const TOOL_EVENT& aEvent )
} }
setEditedPoint( nullptr ); setEditedPoint( nullptr );
updatePoints();
if( valid ) if( valid )
{
commit.Push( _( "Remove a zone/polygon corner" ) ); commit.Push( _( "Remove a zone/polygon corner" ) );
else
commit.Revert();
// Refresh zone hatching // Refresh zone hatching
if( item->Type() == PCB_ZONE_AREA_T) if( item->Type() == PCB_ZONE_AREA_T)
@ -1178,6 +1176,14 @@ int POINT_EDITOR::removeCorner( const TOOL_EVENT& aEvent )
updatePoints(); updatePoints();
} }
else
{
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
getView()->Remove( m_editPoints.get() );
commit.Revert();
m_editPoints.reset();
}
}
return 0; return 0;
} }