From 21a7621ddbe41e79a26bdfa15f371c6e4499d4bd Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 18 May 2019 13:52:03 +0100 Subject: [PATCH] Fix issues with multiple M or G commands in a row. --- eeschema/tools/sch_move_tool.cpp | 39 ++++++++++++++++---------------- eeschema/tools/sch_move_tool.h | 3 +++ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 1786545559..e8cd9e0578 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -120,7 +120,6 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) // Be sure that there is at least one item that we can move. If there's no selection try // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection). SELECTION& selection = m_selectionTool->RequestSelection( movableItems ); - EDA_ITEMS dragAdditions; bool unselect = selection.IsHover(); if( selection.Empty() ) @@ -137,27 +136,24 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) bool restore_state = false; bool chain_commands = false; - bool appendUndo = false; OPT_TOOL_EVENT evt = aEvent; VECTOR2I prevPos; if( m_moveInProgress ) { - // User must have switched from move to drag or vice-versa. Reset the moved items - // so we can start again with the current m_isDragOperation and m_moveOffset. - m_frame->RollbackSchematicFromUndo(); - m_selectionTool->RemoveItemsFromSel( &dragAdditions, QUIET_MODE ); - m_moveInProgress = false; - // And give it a kick so it doesn't have to wait for the first mouse movement to - // refresh. - m_toolMgr->RunAction( EE_ACTIONS::refreshPreview ); + if( !selection.Front()->IsNew() ) + { + // User must have switched from move to drag or vice-versa. Reset the selected + // items so we can start again with the current m_isDragOperation and m_moveOffset. + m_frame->RollbackSchematicFromUndo(); + m_selectionTool->RemoveItemsFromSel( &m_dragAdditions, QUIET_MODE ); + m_moveInProgress = false; + // And give it a kick so it doesn't have to wait for the first mouse movement to + // refresh. + m_toolMgr->RunAction( EE_ACTIONS::refreshPreview ); + } return 0; } - else if( selection.Front()->IsNew() ) - { - // New items will already be on the undo list - appendUndo = true; - } // Main loop: keep receiving events do @@ -170,6 +166,8 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) { if( !m_moveInProgress ) // Prepare to start moving/dragging { + bool appendUndo = selection.Front()->IsNew(); + //------------------------------------------------------------------------ // Setup a drag or a move // @@ -193,11 +191,11 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) static_cast( item )->GetConnectionPoints( connections ); for( wxPoint point : connections ) - getConnectedDragItems( (SCH_ITEM*) item, point, dragAdditions ); + getConnectedDragItems( (SCH_ITEM*) item, point, m_dragAdditions ); } } - m_selectionTool->AddItemsToSel( &dragAdditions, QUIET_MODE ); + m_selectionTool->AddItemsToSel( &m_dragAdditions, QUIET_MODE ); } // Mark the edges of the block with dangling flags for a move. @@ -248,7 +246,8 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) // Apply any initial offset in case we're coming from a previous command. // - moveItem( item, m_moveOffset, m_frame->GetToolId() == ID_SCH_DRAG ); + if( !item->GetParent() || !item->GetParent()->IsSelected() ) + moveItem( item, m_moveOffset, m_frame->GetToolId() == ID_SCH_DRAG ); } // Set up the starting position and move/drag offset @@ -419,11 +418,13 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) if( unselect ) m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); else - m_selectionTool->RemoveItemsFromSel( &dragAdditions, QUIET_MODE ); + m_selectionTool->RemoveItemsFromSel( &m_dragAdditions, QUIET_MODE ); m_frame->OnModify(); } + m_dragAdditions.clear(); + return 0; } diff --git a/eeschema/tools/sch_move_tool.h b/eeschema/tools/sch_move_tool.h index 15f7b36485..d9286f806b 100644 --- a/eeschema/tools/sch_move_tool.h +++ b/eeschema/tools/sch_move_tool.h @@ -71,6 +71,9 @@ private: ///> Flag determining if anything is being dragged right now bool m_moveInProgress; + ///> Items (such as wires) which were added to the selection for a drag + EDA_ITEMS m_dragAdditions; + ///> Used for chaining commands VECTOR2I m_moveOffset;