aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2021-06-07 14:04:27 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-09 14:21:22 +0000
commit4ab966e97651cc4b2344603fd76962f152bbdb2e (patch)
tree330e2bf16bfee6db15abf0fb529a346957bd1c79
parented820383941b68f1fe244895e73ee61ba87c4377 (diff)
Fix high CPU utilization caused by key repeat timer
Key repeat timer has been broken since the beginning. The key repeat timer leaked timer instances while processing the event, causing the accumulation of unprocessed timer events and high CPU utilization. Fix the issue by killing the original timer (long press delay 600 ms) and starting the key repeat timer (repeat delay 50 ms) once. [ChangeLog] Fixed high CPU utilization caused by key repeat timer. Fixes: QTBUG-94259 Change-Id: Iff47249db27cda3750f497cb02c1cb642261e032 Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi> (cherry picked from commit 63a944ff12580f2c333a162ecaecd12419a39c10) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/virtualkeyboard/qvirtualkeyboardinputengine.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/virtualkeyboard/qvirtualkeyboardinputengine.cpp b/src/virtualkeyboard/qvirtualkeyboardinputengine.cpp
index c1675507..54b356b3 100644
--- a/src/virtualkeyboard/qvirtualkeyboardinputengine.cpp
+++ b/src/virtualkeyboard/qvirtualkeyboardinputengine.cpp
@@ -713,9 +713,11 @@ void QVirtualKeyboardInputEngine::timerEvent(QTimerEvent *timerEvent)
{
Q_D(QVirtualKeyboardInputEngine);
if (timerEvent->timerId() == d->repeatTimer) {
- d->repeatTimer = 0;
d->virtualKeyClick(d->activeKey, d->activeKeyText, d->activeKeyModifiers, true);
- d->repeatTimer = startTimer(50);
+ if (!d->repeatCount) {
+ killTimer(d->repeatTimer);
+ d->repeatTimer = startTimer(50);
+ }
d->repeatCount++;
}
}