diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 7876f72bcf..0e84c11d38 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -333,22 +333,11 @@ int EDIT_TOOL::Move( const TOOL_EVENT& aEvent ) totalMovement += movement; // Drag items to the current cursor position - // - // We also refresh the selection VIEW_GROUP here. I'm not sure exactly what - // needs refreshing, but updating the RTREE (via remove/add) doesn't work, nor - // does updating the hidden flag in the view. See bug 1813038. - m_selectionTool->ClearSelection( true /*quiet mode*/ ); - for( EDA_ITEM* item : sel_items ) { - BOARD_ITEM* board_item = (BOARD_ITEM*) item; - // Don't double move footprint pads, fields, etc. - if( item->GetParent() && item->GetParent()->IsSelected() ) - continue; - - board_item->Move( movement ); - m_selectionTool->AddItemToSel( board_item, true /*quiet mode*/ ); + if( !item->GetParent() || !item->GetParent()->IsSelected() ) + static_cast( item )->Move( movement ); } frame()->UpdateMsgPanel(); @@ -475,7 +464,9 @@ int EDIT_TOOL::Move( const TOOL_EVENT& aEvent ) } else + { evt->SetPassEvent(); + } } while( ( evt = Wait() ) ); // Assignment (instead of equality test) is intentional @@ -1014,6 +1005,9 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) // we have a selection to work on now, so start the tool process PCB_BASE_EDIT_FRAME* editFrame = getEditFrame(); + // If the selection was given a hover, we do not keep the selection after completion + bool is_hover = selection.IsHover(); + std::vector new_items; new_items.reserve( selection.Size() ); @@ -1058,6 +1052,12 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) // this works well for "dropping" copies around and pushes the commit TOOL_EVENT evt = PCB_ACTIONS::move.MakeEvent(); Move( evt ); + + // After moving the new items, we need to refresh the group and view flags + m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); + + if( !is_hover ) + m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &new_items ); } return 0;