From f7863bfdb90f25fa62a395f8bc80641a54c69179 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 11 Sep 2020 10:50:57 +0200 Subject: [PATCH] QAbstractSpinBox: don't emit update signals twice A QAbstractSpinBox has a spinClickThresholdTimer that is detecting if the user is doing a press'n'hold on one of the spin buttons, to activate auto-repeat. But if the valueChanged() handler in the application spends too much time before it returns, the spinClickThresholdTimer will fire before we get a chance to cancel it from the pending mouseRelease event. The result is that the spinbox will think that the user is doing a press'n'hold, and increment the value once more. To avoid this, we start the timer _after_ the call to valueChanged() instead. Pick-to: 5.15 Fixes: QTBUG-86483 Change-Id: Iff5de4f8da562738e02848c98bc1fbc9fe227748 Reviewed-by: Friedemann Kleint Reviewed-by: Volker Hilsheimer --- src/widgets/widgets/qabstractspinbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 154957eea3..b9b62bbaaa 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1678,12 +1678,12 @@ void QAbstractSpinBoxPrivate::updateState(bool up, bool fromKeyboard /* = false reset(); if (q && (q->stepEnabled() & (up ? QAbstractSpinBox::StepUpEnabled : QAbstractSpinBox::StepDownEnabled))) { - spinClickThresholdTimerId = q->startTimer(spinClickThresholdTimerInterval); buttonState = (up ? Up : Down) | (fromKeyboard ? Keyboard : Mouse); int steps = up ? 1 : -1; if (keyboardModifiers & stepModifier) steps *= 10; q->stepBy(steps); + spinClickThresholdTimerId = q->startTimer(spinClickThresholdTimerInterval); #ifndef QT_NO_ACCESSIBILITY QAccessibleValueChangeEvent event(q, value); QAccessible::updateAccessibility(&event);