From 0ff20c18a3482b00e745a5990383da148fd093ca Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 7 Sep 2019 20:51:30 +0100 Subject: [PATCH] More direct selection handling. Fixes: lp:1842750 * https://bugs.launchpad.net/kicad/+bug/1842750 --- eeschema/tools/lib_edit_tool.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/eeschema/tools/lib_edit_tool.cpp b/eeschema/tools/lib_edit_tool.cpp index 8eae01a6e8..278a65808a 100644 --- a/eeschema/tools/lib_edit_tool.cpp +++ b/eeschema/tools/lib_edit_tool.cpp @@ -721,6 +721,8 @@ int LIB_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) if( !selection.Front()->IsMoving() ) saveCopyInUndoList( m_frame->GetCurPart(), UR_LIBEDIT ); + EDA_ITEMS newItems; + for( unsigned ii = 0; ii < selection.GetSize(); ++ii ) { LIB_ITEM* oldItem = static_cast( selection.GetItem( ii ) ); @@ -728,18 +730,17 @@ int LIB_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) oldItem->ClearFlags( SELECTED ); newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED ); newItem->SetParent( part ); + newItems.push_back( newItem ); part->GetDrawItems().push_back( newItem ); getView()->Add( newItem ); } - m_selectionTool->RebuildSelection(); + m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); + m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems ); - if( !selection.Empty() ) - { - selection.SetReferencePoint( mapCoords( getViewControls()->GetCursorPosition( true ) ) ); - m_toolMgr->RunAction( EE_ACTIONS::move, false ); - } + selection.SetReferencePoint( mapCoords( getViewControls()->GetCursorPosition( true ) ) ); + m_toolMgr->RunAction( EE_ACTIONS::move, false ); return 0; }