Don't deselected items that have been deleted.
De-referencing freed memory is never a good idea. Fixes: lp:1795195 * https://bugs.launchpad.net/kicad/+bug/1795195
This commit is contained in:
parent
ef6f7e96f3
commit
f06bf81651
|
@ -61,12 +61,12 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
|||
{
|
||||
// Objects potentially interested in changes:
|
||||
PICKED_ITEMS_LIST undoList;
|
||||
KIGFX::VIEW* view = m_toolMgr->GetView();
|
||||
BOARD* board = (BOARD*) m_toolMgr->GetModel();
|
||||
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) m_toolMgr->GetEditFrame();
|
||||
auto connectivity = board->GetConnectivity();
|
||||
std::set<EDA_ITEM*> savedModules;
|
||||
std::vector<BOARD_ITEM*> itemsToRemove;
|
||||
KIGFX::VIEW* view = m_toolMgr->GetView();
|
||||
BOARD* board = (BOARD*) m_toolMgr->GetModel();
|
||||
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) m_toolMgr->GetEditFrame();
|
||||
auto connectivity = board->GetConnectivity();
|
||||
std::set<EDA_ITEM*> savedModules;
|
||||
std::vector<BOARD_ITEM*> itemsToDeselect;
|
||||
|
||||
if( Empty() )
|
||||
return;
|
||||
|
@ -142,11 +142,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
|||
case CHT_REMOVE:
|
||||
{
|
||||
if( !m_editModules && aCreateUndoEntry )
|
||||
{
|
||||
undoList.PushItem( ITEM_PICKER( boardItem, UR_DELETED ) );
|
||||
}
|
||||
|
||||
itemsToRemove.push_back( boardItem );
|
||||
|
||||
switch( boardItem->Type() )
|
||||
{
|
||||
|
@ -190,6 +186,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
|||
case PCB_MARKER_T: // a marker used to show something
|
||||
case PCB_SEGZONE_T: // SEG_ZONE items are now deprecated
|
||||
case PCB_ZONE_AREA_T:
|
||||
itemsToDeselect.push_back( boardItem );
|
||||
|
||||
view->Remove( boardItem );
|
||||
|
||||
if( !( changeFlags & CHT_DONE ) )
|
||||
|
@ -254,10 +252,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
|||
// Removing an item should trigger the unselect action
|
||||
// but only after all items are removed otherwise we can get
|
||||
// flickering depending on the system
|
||||
if( itemsToRemove.size() > 0 )
|
||||
{
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::unselectItems, true, &itemsToRemove );
|
||||
}
|
||||
if( itemsToDeselect.size() > 0 )
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::unselectItems, true, &itemsToDeselect );
|
||||
|
||||
if( !m_editModules && aCreateUndoEntry )
|
||||
frame->SaveCopyInUndoList( undoList, UR_UNSPECIFIED );
|
||||
|
|
|
@ -853,7 +853,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
|
|||
return 0;
|
||||
|
||||
// get a copy instead of reference (as we're going to clear the selection before removing items)
|
||||
auto selection = m_selectionTool->RequestSelection(
|
||||
auto selectionCopy = m_selectionTool->RequestSelection(
|
||||
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
|
||||
{ EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED | EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); } );
|
||||
|
||||
|
@ -862,20 +862,20 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
|
|||
|
||||
// in "alternative" mode, deletion is not just a simple list of selected items,
|
||||
// it removes whole tracks, not just segments
|
||||
if( isAlt && selection.IsHover()
|
||||
&& ( selection.HasType( PCB_TRACE_T ) || selection.HasType( PCB_VIA_T ) ) )
|
||||
if( isAlt && selectionCopy.IsHover()
|
||||
&& ( selectionCopy.HasType( PCB_TRACE_T ) || selectionCopy.HasType( PCB_VIA_T ) ) )
|
||||
{
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::expandSelectedConnection, true );
|
||||
selection = m_selectionTool->GetSelection();
|
||||
selectionCopy = m_selectionTool->GetSelection();
|
||||
}
|
||||
|
||||
if( selection.Empty() )
|
||||
if( selectionCopy.Empty() )
|
||||
return 0;
|
||||
|
||||
// As we are about to remove items, they have to be removed from the selection first
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
for( auto item : selection )
|
||||
for( auto item : selectionCopy )
|
||||
{
|
||||
if( m_editModules )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue