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
|
@ -66,7 +66,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
||||||
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) m_toolMgr->GetEditFrame();
|
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) m_toolMgr->GetEditFrame();
|
||||||
auto connectivity = board->GetConnectivity();
|
auto connectivity = board->GetConnectivity();
|
||||||
std::set<EDA_ITEM*> savedModules;
|
std::set<EDA_ITEM*> savedModules;
|
||||||
std::vector<BOARD_ITEM*> itemsToRemove;
|
std::vector<BOARD_ITEM*> itemsToDeselect;
|
||||||
|
|
||||||
if( Empty() )
|
if( Empty() )
|
||||||
return;
|
return;
|
||||||
|
@ -142,11 +142,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
||||||
case CHT_REMOVE:
|
case CHT_REMOVE:
|
||||||
{
|
{
|
||||||
if( !m_editModules && aCreateUndoEntry )
|
if( !m_editModules && aCreateUndoEntry )
|
||||||
{
|
|
||||||
undoList.PushItem( ITEM_PICKER( boardItem, UR_DELETED ) );
|
undoList.PushItem( ITEM_PICKER( boardItem, UR_DELETED ) );
|
||||||
}
|
|
||||||
|
|
||||||
itemsToRemove.push_back( boardItem );
|
|
||||||
|
|
||||||
switch( boardItem->Type() )
|
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_MARKER_T: // a marker used to show something
|
||||||
case PCB_SEGZONE_T: // SEG_ZONE items are now deprecated
|
case PCB_SEGZONE_T: // SEG_ZONE items are now deprecated
|
||||||
case PCB_ZONE_AREA_T:
|
case PCB_ZONE_AREA_T:
|
||||||
|
itemsToDeselect.push_back( boardItem );
|
||||||
|
|
||||||
view->Remove( boardItem );
|
view->Remove( boardItem );
|
||||||
|
|
||||||
if( !( changeFlags & CHT_DONE ) )
|
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
|
// Removing an item should trigger the unselect action
|
||||||
// but only after all items are removed otherwise we can get
|
// but only after all items are removed otherwise we can get
|
||||||
// flickering depending on the system
|
// flickering depending on the system
|
||||||
if( itemsToRemove.size() > 0 )
|
if( itemsToDeselect.size() > 0 )
|
||||||
{
|
m_toolMgr->RunAction( PCB_ACTIONS::unselectItems, true, &itemsToDeselect );
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::unselectItems, true, &itemsToRemove );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !m_editModules && aCreateUndoEntry )
|
if( !m_editModules && aCreateUndoEntry )
|
||||||
frame->SaveCopyInUndoList( undoList, UR_UNSPECIFIED );
|
frame->SaveCopyInUndoList( undoList, UR_UNSPECIFIED );
|
||||||
|
|
|
@ -853,7 +853,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// get a copy instead of reference (as we're going to clear the selection before removing items)
|
// 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 )
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
|
||||||
{ EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED | EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); } );
|
{ 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,
|
// in "alternative" mode, deletion is not just a simple list of selected items,
|
||||||
// it removes whole tracks, not just segments
|
// it removes whole tracks, not just segments
|
||||||
if( isAlt && selection.IsHover()
|
if( isAlt && selectionCopy.IsHover()
|
||||||
&& ( selection.HasType( PCB_TRACE_T ) || selection.HasType( PCB_VIA_T ) ) )
|
&& ( selectionCopy.HasType( PCB_TRACE_T ) || selectionCopy.HasType( PCB_VIA_T ) ) )
|
||||||
{
|
{
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::expandSelectedConnection, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::expandSelectedConnection, true );
|
||||||
selection = m_selectionTool->GetSelection();
|
selectionCopy = m_selectionTool->GetSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( selection.Empty() )
|
if( selectionCopy.Empty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// As we are about to remove items, they have to be removed from the selection first
|
// As we are about to remove items, they have to be removed from the selection first
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
for( auto item : selection )
|
for( auto item : selectionCopy )
|
||||||
{
|
{
|
||||||
if( m_editModules )
|
if( m_editModules )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue