From 6d76097291c57136583fcbd3a6bd24811bb7d10e Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 12 Nov 2018 21:59:02 +0000 Subject: [PATCH] When running selectable() recursively, we're really only checking visibility. Fixes: lp:1802949 * https://bugs.launchpad.net/kicad/+bug/1802949 --- pcbnew/tools/selection_tool.cpp | 27 ++++++++++++++++----------- pcbnew/tools/selection_tool.h | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 615811db1e..b89a5e7e7c 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -1527,7 +1527,7 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector } -bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem, bool ignoreMultipleFlag ) const +bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem, bool checkVisibilityOnly ) const { // Is high contrast mode enabled? bool highContrast = getView()->GetPainter()->GetSettings()->GetHighContrast(); @@ -1653,8 +1653,11 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem, bool ignoreMultipleFla // Multiple selection is only allowed in modedit mode. In pcbnew, you have to select // module subparts one by one, rather than with a drag selection. This is so you can // pick up items under an (unlocked) module without also moving the module's sub-parts. - if( m_multiple && !ignoreMultipleFlag && !m_editModules ) - return false; + if( !m_editModules && !checkVisibilityOnly ) + { + if( m_multiple ) + return false; + } if( !m_editModules && !view()->IsVisible( aItem ) ) return false; @@ -1667,15 +1670,9 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem, bool ignoreMultipleFla // Multiple selection is only allowed in modedit mode. In pcbnew, you have to select // module subparts one by one, rather than with a drag selection. This is so you can // pick up items under an (unlocked) module without also moving the module's sub-parts. - if( m_multiple && !ignoreMultipleFlag && !m_editModules ) - return false; - - // In pcbnew, locked modules prevent individual pad selection. - // In modedit, we don't enforce this as the module is assumed to be edited by design. - if( !m_editModules ) + if( !m_editModules && !checkVisibilityOnly ) { - MODULE* mod = static_cast( aItem )->GetParent(); - if( mod && mod->IsLocked() ) + if( m_multiple ) return false; } @@ -1683,6 +1680,14 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem, bool ignoreMultipleFla { auto pad = static_cast( aItem ); + // In pcbnew, locked modules prevent individual pad selection. + // In modedit, we don't enforce this as the module is assumed to be edited by design. + if( !m_editModules && !checkVisibilityOnly ) + { + if( pad->GetParent() && pad->GetParent()->IsLocked() ) + return false; + } + // Check render mode (from the Items tab) first switch( pad->GetAttribute() ) { diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index 65852f4a1f..2ec519c5de 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -273,7 +273,7 @@ private: * * @return True if the item fulfills conditions to be selected. */ - bool selectable( const BOARD_ITEM* aItem, bool ignoreMultipleFlag = false ) const; + bool selectable( const BOARD_ITEM* aItem, bool checkVisibilityOnly = false ) const; /** * Function select()