Fix event processing bug which kept ModEdit's context menu from working.

This commit is contained in:
Jeff Young 2020-09-18 11:47:51 +01:00
parent 34527630d0
commit 1a988e8d85
1 changed files with 35 additions and 35 deletions

View File

@ -665,10 +665,11 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
}
}
// If we're pendingWait then we had better have a cofunc to process the wait.
wxASSERT( !st || !st->pendingWait || st->cofunc );
// the tool state handler is waiting for events (i.e. called Wait() method)
if( st && st->pendingWait )
{
if( st->waitEvents.Matches( aEvent ) )
if( st && st->cofunc && st->pendingWait && st->waitEvents.Matches( aEvent ) )
{
if( !aEvent.FirstResponder() )
const_cast<TOOL_EVENT*>( &aEvent )->SetFirstResponder( st->theTool );
@ -678,8 +679,6 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
st->pendingWait = false;
st->waitEvents.clear();
if( st->cofunc )
{
wxLogTrace( kicadTraceToolStack,
"TOOL_MANAGER::dispatchInternal - Waking tool %s for event: %s",
st->theTool->GetName(), aEvent.Format() );
@ -692,7 +691,6 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
it = finishTool( st );
increment = false;
}
}
// If the tool did not request the event be passed to other tools, we're done
if( !st->wakeupEvent.PassEvent() )
@ -704,7 +702,6 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
return true;
}
}
}
if( increment )
++it;
@ -821,8 +818,11 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent )
if( st->contextMenuTrigger == CMENU_BUTTON && !aEvent.IsClick( BUT_RIGHT ) )
break;
if( st->cofunc )
{
st->pendingWait = true;
st->waitEvents = TOOL_EVENT( TC_ANY, TA_ANY );
}
// Store the menu pointer in case it is changed by the TOOL when handling menu events
ACTION_MENU* m = st->contextMenu;