Don't inadventently clear selection reference point.

New algorithm more targetted and just clears the items.  This
also obviates the need for the aQuietMode flags.

Only fixes one part of the bug, but the "fixes" line is the
easiest way to get a link in the bug to the commit.

Fixes: lp:1786727
* https://bugs.launchpad.net/kicad/+bug/1786727
This commit is contained in:
Jeff Young 2018-08-22 15:09:16 +01:00
parent 60a55d75fa
commit c91e51f688
3 changed files with 21 additions and 29 deletions

View File

@ -1192,11 +1192,9 @@ void PCBNEW_CONTROL::setTransitions()
Go( &PCBNEW_CONTROL::ToBeDone, PCB_ACTIONS::toBeDone.MakeEvent() );
// Append control
Go( &PCBNEW_CONTROL::AppendBoardFromFile,
PCB_ACTIONS::appendBoard.MakeEvent() );
Go( &PCBNEW_CONTROL::AppendBoardFromFile, PCB_ACTIONS::appendBoard.MakeEvent() );
Go( &PCBNEW_CONTROL::PasteItemsFromClipboard,
PCB_ACTIONS::pasteFromClipboard.MakeEvent() );
Go( &PCBNEW_CONTROL::PasteItemsFromClipboard, PCB_ACTIONS::pasteFromClipboard.MakeEvent() );
}

View File

@ -394,38 +394,40 @@ SELECTION& SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aClientFilt
{
GENERAL_COLLECTOR collector;
for( auto item : m_selection.Items() )
collector.Append( item );
while( m_selection.GetSize() )
{
collector.Append( m_selection.Front() );
unselect( static_cast<BOARD_ITEM*>( m_selection.Front() ) );
}
aClientFilter( VECTOR2I(), collector );
clearSelection( true );
for( int i = 0; i < collector.GetCount(); ++i )
{
m_additive = true;
toggleSelection( collector[ i ], true );
select( collector[ i ] );
}
m_frame->GetGalCanvas()->ForceRefresh();
}
return m_selection;
}
void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem, bool aQuietMode )
void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
{
if( aItem->IsSelected() )
{
unselect( aItem );
// Inform other potentially interested tools
if( !aQuietMode )
m_toolMgr->ProcessEvent( UnselectedEvent );
m_toolMgr->ProcessEvent( UnselectedEvent );
}
else
{
if( !m_additive )
clearSelection( aQuietMode );
clearSelection();
// Prevent selection of invisible or inactive items
if( selectable( aItem ) )
@ -433,8 +435,7 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem, bool aQuietMode )
select( aItem );
// Inform other potentially interested tools
if( !aQuietMode )
m_toolMgr->ProcessEvent( SelectedEvent );
m_toolMgr->ProcessEvent( SelectedEvent );
}
}
@ -1369,7 +1370,7 @@ int SELECTION_TOOL::filterSelection( const TOOL_EVENT& aEvent )
}
void SELECTION_TOOL::clearSelection( bool aQuietMode )
void SELECTION_TOOL::clearSelection()
{
if( m_selection.Empty() )
return;
@ -1390,8 +1391,7 @@ void SELECTION_TOOL::clearSelection( bool aQuietMode )
m_locked = true;
// Inform other potentially interested tools
if( !aQuietMode )
m_toolMgr->ProcessEvent( ClearedEvent );
m_toolMgr->ProcessEvent( ClearedEvent );
}
@ -1778,14 +1778,11 @@ void SELECTION_TOOL::unselect( BOARD_ITEM* aItem )
unhighlight( aItem, SELECTED, m_selection );
view()->Update( &m_selection );
if( m_frame && m_frame->GetCurItem() == aItem )
m_frame->SetCurItem( NULL );
if( m_selection.Empty() )
{
if( m_frame )
{
m_frame->SetCurItem( NULL );
}
m_locked = true;
}
}

View File

@ -248,10 +248,8 @@ private:
/**
* Function clearSelection()
* Clears the current selection.
*
* @param aQuietMode if true selection events are not broadcast to other tools.
*/
void clearSelection( bool aQuietMode = false );
void clearSelection();
/**
* Function pickSmallestComponent()
@ -266,9 +264,8 @@ 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, bool aQuietMode = false );
void toggleSelection( BOARD_ITEM* aItem );
/**
* Function selectable()