Cancel preceeding command if Move was called to place it.

Fixes https://gitlab.com/kicad/code/kicad/issues/5252
This commit is contained in:
Jeff Young 2020-08-19 13:13:12 +01:00
parent d3d90ddb67
commit 2bf4fcae2a
1 changed files with 22 additions and 2 deletions

View File

@ -379,6 +379,7 @@ int EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, bool aPickReference )
}
bool restore_state = false;
bool fromOtherCommand = false;
VECTOR2I totalMovement;
GRID_HELPER grid( m_toolMgr, editFrame->GetMagneticItemsSettings() );
TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
@ -483,6 +484,9 @@ int EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, bool aPickReference )
m_commit->Modify( bItem );
});
}
if( item->IsNew() )
fromOtherCommand = true;
}
}
@ -615,9 +619,25 @@ int EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, bool aPickReference )
// If canceled, we need to remove the dynamic ratsnest from the screen
if( restore_state )
{
m_commit->Revert();
if( fromOtherCommand )
{
PICKED_ITEMS_LIST* undo = editFrame->PopCommandFromUndoList();
if( undo )
{
editFrame->PutDataInPreviousState( undo, false );
undo->ClearListAndDeleteItems();
delete undo;
}
}
}
else
{
m_commit->Push( _( "Drag" ) );
}
m_toolMgr->RunAction( PCB_ACTIONS::hideDynamicRatsnest, true );