Try harder to avoid loop contention

We have two cases where we might be requesting a disambiguation menu.
In one case, we already have the event loop waiting and we need to run
the selectionMenu through the action system.  In the other case, the
tool isn't on the stack and won't activate.  Here we need to run
directly and we are assured of not crashing because the tool isn't
active.

Fixes https://gitlab.com/kicad/code/kicad/issues/9154
This commit is contained in:
Seth Hillbrand 2021-09-13 10:14:59 -07:00
parent b27b97809f
commit 484eaa01b9
1 changed files with 7 additions and 1 deletions

View File

@ -851,7 +851,13 @@ bool EE_SELECTION_TOOL::selectPoint( EE_COLLECTOR& aCollector, EDA_ITEM** aItem,
// If still more than one item we're going to have to ask the user.
if( aCollector.GetCount() > 1 )
{
if( !doSelectionMenu( &aCollector ) || aCollector.m_MenuCancelled )
// Try to call selectionMenu via RunAction() to avoid event-loop contention
// But it we cannot handle the event, then we don't have an active tool loop, so
// handle it directly.
if( !m_toolMgr->RunAction( EE_ACTIONS::selectionMenu, true, &aCollector ) )
doSelectionMenu( &aCollector );
if( aCollector.m_MenuCancelled )
{
if( aSelectionCancelledFlag )
*aSelectionCancelledFlag = true;