Fix double disambiguation menu when removing footprints

Second disambiguation menu was caused by another call to
SELECTION_TOOL::RequestSelection() meant to get the list of
connected tracks. When there were only footprints under the cursor,
it asked the user again to pick an item to remove.

Fixes: lp:1748521
* https://bugs.launchpad.net/kicad/+bug/1748521
This commit is contained in:
Maciej Suminski 2018-02-12 10:17:35 +01:00
parent ed127e866a
commit 4f0c9b6b20
2 changed files with 25 additions and 11 deletions

View File

@ -168,6 +168,23 @@ public:
return nullptr; return nullptr;
} }
/**
* Checks if there is at least one item of requested kind.
*
* @param aType is the type to check for.
* @return True if there is at least one item of such kind.
*/
bool HasType( KICAD_T aType ) const
{
for( auto item : m_items )
{
if( item->Type() == aType )
return true;
}
return false;
}
virtual const VIEW_GROUP::ITEMS updateDrawList() const override; virtual const VIEW_GROUP::ITEMS updateDrawList() const override;
bool HasReferencePoint() const bool HasReferencePoint() const

View File

@ -843,29 +843,26 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
if( m_selectionTool->CheckLock() == SELECTION_LOCKED ) if( m_selectionTool->CheckLock() == SELECTION_LOCKED )
return 0; return 0;
if( selection.Empty() )
return 0;
// is this "alternative" remove? // is this "alternative" remove?
const bool isAlt = aEvent.Parameter<intptr_t>() == const bool isAlt = aEvent.Parameter<intptr_t>() == (int) PCB_ACTIONS::REMOVE_FLAGS::ALT;
(int) PCB_ACTIONS::REMOVE_FLAGS::ALT;
// in "alternative" mode, deletion is not just a simple list // in "alternative" mode, deletion is not just a simple list of selected items,
// of selected items, it is: // it removes whole tracks, not just segments
// - whole tracks, not just segments if( isAlt && selection.IsHover()
if( isAlt && selection.IsHover() ) && ( selection.HasType( PCB_TRACE_T ) || selection.HasType( PCB_VIA_T ) ) )
{ {
m_toolMgr->RunAction( PCB_ACTIONS::selectConnection, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectConnection, true );
selection = m_selectionTool->RequestSelection( SELECTION_DELETABLE | SELECTION_SANITIZE_PADS ); selection = m_selectionTool->RequestSelection( SELECTION_DELETABLE | SELECTION_SANITIZE_PADS );
} }
if( selection.Empty() )
return 0;
// As we are about to remove items, they have to be removed from the selection first // As we are about to remove items, they have to be removed from the selection first
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
for( auto item : selection ) for( auto item : selection )
{
m_commit->Remove( item ); m_commit->Remove( item );
}
m_commit->Push( _( "Delete" ) ); m_commit->Push( _( "Delete" ) );