Don't broadcast events when running client selection filters.

Some other tools (in this case the POINT_EDITOR) aren't good
citizens and activate themselves when receiving selection
changes.

Fixes: lp:1785781
* https://bugs.launchpad.net/kicad/+bug/1785781
This commit is contained in:
Jeff Young 2018-08-08 01:43:34 +01:00
parent 99ed476de1
commit a9fa66bb41
2 changed files with 16 additions and 12 deletions

View File

@ -399,12 +399,12 @@ SELECTION& SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aClientFilt
aClientFilter( VECTOR2I(), collector );
clearSelection();
clearSelection( true );
for( int i = 0; i < collector.GetCount(); ++i )
{
m_additive = true;
toggleSelection( collector[ i ] );
toggleSelection( collector[ i ], true );
}
}
@ -412,19 +412,20 @@ SELECTION& SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aClientFilt
}
void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem, bool aQuietMode )
{
if( aItem->IsSelected() )
{
unselect( aItem );
// Inform other potentially interested tools
m_toolMgr->ProcessEvent( UnselectedEvent );
if( !aQuietMode )
m_toolMgr->ProcessEvent( UnselectedEvent );
}
else
{
if( !m_additive )
clearSelection();
clearSelection( aQuietMode );
// Prevent selection of invisible or inactive items
if( selectable( aItem ) )
@ -432,14 +433,13 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
select( aItem );
// Inform other potentially interested tools
m_toolMgr->ProcessEvent( SelectedEvent );
if( !aQuietMode )
m_toolMgr->ProcessEvent( SelectedEvent );
}
}
if( m_frame )
{
m_frame->GetGalCanvas()->ForceRefresh();
}
}
const GENERAL_COLLECTORS_GUIDE SELECTION_TOOL::getCollectorsGuide() const
@ -1367,7 +1367,7 @@ int SELECTION_TOOL::filterSelection( const TOOL_EVENT& aEvent )
}
void SELECTION_TOOL::clearSelection()
void SELECTION_TOOL::clearSelection( bool aQuietMode )
{
if( m_selection.Empty() )
return;
@ -1388,7 +1388,8 @@ void SELECTION_TOOL::clearSelection()
m_locked = true;
// Inform other potentially interested tools
m_toolMgr->ProcessEvent( ClearedEvent );
if( !aQuietMode )
m_toolMgr->ProcessEvent( ClearedEvent );
}

View File

@ -248,8 +248,10 @@ private:
/**
* Function clearSelection()
* Clears the current selection.
*
* @param aQuietMode if true selection events are not broadcast to other tools.
*/
void clearSelection();
void clearSelection( bool aQuietMode = false );
/**
* Function pickSmallestComponent()
@ -264,8 +266,9 @@ private:
* Changes selection status of a given item.
*
* @param aItem is the item to have selection status changed.
* @param aQuietMode if true selection events are not broadcast to other tools.
*/
void toggleSelection( BOARD_ITEM* aItem );
void toggleSelection( BOARD_ITEM* aItem, bool aQuietMode = false );
/**
* Function selectable()