From 484eaa01b9503a007eb62bc4e91cdc5956e9cd5a Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 13 Sep 2021 10:14:59 -0700 Subject: [PATCH] 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 --- eeschema/tools/ee_selection_tool.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 737c3389d7..444593f222 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -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;