From d50bc6a85f89ac4e967ab429a3c4919745709da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C5=82ostowski?= Date: Wed, 16 Jan 2019 17:00:38 +0100 Subject: [PATCH] EDIT_TOOL: correctly handle locked items in Rotate/Flip/Mirror functions when the selection is already being dragged Fixes: lp:1812009 * https://bugs.launchpad.net/kicad/+bug/1812009 --- pcbnew/tools/edit_tool.cpp | 6 +++--- pcbnew/tools/selection_tool.cpp | 10 ++++++++-- pcbnew/tools/selection_tool.h | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 21cb0a8880..1a3b0c4b46 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -672,7 +672,7 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) auto& selection = m_selectionTool->RequestSelection( []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector ) - { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED | EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); } ); + { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); }, nullptr, ! m_dragging ); if( selection.Empty() ) return 0; @@ -751,7 +751,7 @@ int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) { auto& selection = m_selectionTool->RequestSelection( []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector ) - { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED | EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); } ); + { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); }, nullptr, ! m_dragging ); if( selection.Empty() ) return 0; @@ -833,7 +833,7 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent ) { auto& selection = m_selectionTool->RequestSelection( []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector ) - { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED | EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); } ); + { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); }, nullptr, ! m_dragging ); if( selection.Empty() ) return 0; diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index ca209e2250..d4899be236 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -396,7 +396,7 @@ static EDA_RECT getRect( const BOARD_ITEM* aItem ) SELECTION& SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aClientFilter, - std::vector* aFiltered ) + std::vector* aFiltered, bool aConfirmLockedItems ) { bool selectionEmpty = m_selection.Empty(); m_selection.SetIsHover( selectionEmpty ); @@ -406,7 +406,13 @@ SELECTION& SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aClientFilt m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true, aClientFilter ); m_selection.ClearReferencePoint(); } - else if( aClientFilter ) + + if ( aConfirmLockedItems && CheckLock() == SELECTION_LOCKED ) + { + clearSelection(); + } + + if( aClientFilter ) { GENERAL_COLLECTOR collector; diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index 10b86cfc93..02de875e5c 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -96,7 +96,7 @@ public: * @param aFiltered is an optional vector, that is filled with items removed by the filter */ SELECTION& RequestSelection( CLIENT_SELECTION_FILTER aClientFilter, - std::vector* aFiltered = NULL ); + std::vector* aFiltered = NULL, bool aConfirmLockedItems = false ); inline TOOL_MENU& GetToolMenu()