diff options
author | Andy Shaw <andy.shaw@digia.com> | 2013-08-26 12:05:54 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-03 08:23:20 +0200 |
commit | cdbf8dd276a2b6f3544a4e67e1216a1b8ca9f29e (patch) | |
tree | 61b1891138c2f42c598fd874eddd9eaefc4b1496 /src | |
parent | 0278310f9e27b1c6aca6bd70dc5415a240cd33c3 (diff) |
Ensure the timer is killed when appropriate before starting a new one
When the mouse moves while the sloppy menu timer is still running then it
would end up just creating a new one and the old one would continue to
run. If the action that it is relevant for is different then it should
restart the timer, otherwise it should just ignore the mouse move and let
the other timer continue.
Change-Id: Id03014fa05596bd6ede887fa917e21ca5a7690d8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/widgets/qmenu.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 4df89a5ede..c305748c7d 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -2864,8 +2864,15 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) d->mouseDown = this; } if (d->sloppyRegion.contains(e->pos())) { - d->sloppyAction = action; - QMenuPrivate::sloppyDelayTimer = startTimer(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)*6); + // If the timer is already running then don't start a new one unless the action is the same + if (d->sloppyAction != action && QMenuPrivate::sloppyDelayTimer != 0) { + killTimer(QMenuPrivate::sloppyDelayTimer); + QMenuPrivate::sloppyDelayTimer = 0; + } + if (QMenuPrivate::sloppyDelayTimer == 0) { + d->sloppyAction = action; + QMenuPrivate::sloppyDelayTimer = startTimer(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this) * 6); + } } else if (action != d->currentAction) { d->setCurrentAction(action, style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)); } |