From c3ea0876c147d255611c699e75da2f4bcff41617 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Thu, 10 Feb 2022 11:51:25 -0600 Subject: [PATCH] Process Qukeys queue after checking timeout in afterEachCycle() To prevent the possibility of a call to `flushEvent()` when the queue is empty, we call `processQueue()` (which checks for an empty queue) after checking the hold timeout, rather than before. Signed-off-by: Michael Richters --- .../Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp index 72ecc8c4..bc9a63dc 100644 --- a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp +++ b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp @@ -88,9 +88,6 @@ EventHandlerResult Qukeys::afterEachCycle() { return EventHandlerResult::OK; } - // Process as many events as we can from the queue. - while (processQueue()); - // If we get here, that means that the first event in the queue is a qukey // press. All that's left to do is to check if it's been held long enough that // it has timed out. @@ -101,6 +98,10 @@ EventHandlerResult Qukeys::afterEachCycle() { queue_head_.primary_key : queue_head_.alternate_key; flushEvent(event_key); } + + // Process as many events as we can from the queue. + while (processQueue()); + return EventHandlerResult::OK; }