summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorPavel Krebs <pkrebs@amberg.cz>2014-12-05 15:39:48 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-12-19 17:15:07 +0100
commit1c1cce67fa1d03a49cdfb6f1ca378b182925ffdb (patch)
tree9957997cf2e4beb1648ba6d46c47c738aa6204ed /src/widgets
parentb6514cf30761b01b477edef67217a48a59268886 (diff)
QScrollBar: emit valueChanged once even if a slot takes too much time
Put also processing of control activation into initial timer check for possibly pending mouse release event. [ChangeLog][QtWidgets][QScrollBar] Fixed a bug where the valueChanged() signal was emitted twice if a connected slot took too much time. Task-number: QTBUG-42871 Change-Id: I7bad5279ef84463a033b55256d241d4445374081 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qscrollbar.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp
index 5851020379..c2d2117e20 100644
--- a/src/widgets/widgets/qscrollbar.cpp
+++ b/src/widgets/widgets/qscrollbar.cpp
@@ -593,13 +593,14 @@ void QScrollBar::mousePressEvent(QMouseEvent *e)
d->clickOffset = sliderLength / 2;
}
const int initialDelay = 500; // default threshold
- d->activateControl(d->pressedControl, initialDelay);
QElapsedTimer time;
time.start();
+ d->activateControl(d->pressedControl, initialDelay);
repaint(style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this));
if (time.elapsed() >= initialDelay && d->repeatActionTimer.isActive()) {
- // It took more than 500ms (the initial timer delay) to process the repaint(), we
- // therefore need to restart the timer in case we have a pending mouse release event;
+ // It took more than 500ms (the initial timer delay) to process
+ // the control activation and repaint(), we therefore need
+ // to restart the timer in case we have a pending mouse release event;
// otherwise we'll get a timer event right before the release event,
// causing the repeat action to be invoked twice on a single mouse click.
// 50ms is the default repeat time (see activateControl/setRepeatAction).