From cdbf8dd276a2b6f3544a4e67e1216a1b8ca9f29e Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 26 Aug 2013 12:05:54 +0200 Subject: 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 --- src/widgets/widgets/qmenu.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/widgets/widgets/qmenu.cpp') 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)); } -- cgit v1.2.3