From 020d873a5753c4c147d11ac98682d270554e1d05 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 18 Mar 2014 12:50:23 +0100 Subject: [PATCH] QMenuPrivate: Make sloppyDelayTimer non-static Keeping the timer static would trigger warnings when enabling SH_Menu_SloppySubMenus in QCommonStyle in a forthcoming patch. This would happen if we opened a second level submenu quickly enough and get the mouse event handler to reset the timer its parent menu started. This is a backport of Ia768603b40b219f87138c60a595c65ef408761ae from qt/qtbase. Change-Id: Ia7e9a94b3445d9362a60a36d5e4dda878ab0f7a5 Reviewed-by: J-P Nurmi Reviewed-by: Lars Knoll --- src/gui/widgets/qmenu.cpp | 9 ++++----- src/gui/widgets/qmenu_p.h | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index db3d7cd..2a7477a 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -90,7 +90,6 @@ QT_BEGIN_NAMESPACE QMenu *QMenuPrivate::mouseDown = 0; -int QMenuPrivate::sloppyDelayTimer = 0; /* QMenu code */ // internal class used for the torn off popup @@ -2874,7 +2873,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) } if (d->sloppyRegion.contains(e->pos())) { d->sloppyAction = action; - QMenuPrivate::sloppyDelayTimer = startTimer(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)*6); + d->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)); } @@ -2915,9 +2914,9 @@ QMenu::timerEvent(QTimerEvent *e) } else if(d->menuDelayTimer.timerId() == e->timerId()) { d->menuDelayTimer.stop(); internalDelayedPopup(); - } else if(QMenuPrivate::sloppyDelayTimer == e->timerId()) { - killTimer(QMenuPrivate::sloppyDelayTimer); - QMenuPrivate::sloppyDelayTimer = 0; + } else if (d->sloppyDelayTimer == e->timerId()) { + killTimer(d->sloppyDelayTimer); + d->sloppyDelayTimer = 0; internalSetSloppyAction(); } else if(d->searchBufferTimer.timerId() == e->timerId()) { d->searchBuffer.clear(); diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index 71679a0..3c93d0b 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -153,7 +153,7 @@ public: cancelAction(0), #endif scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0), - hasCheckableItems(0), sloppyAction(0), doChildEffects(false) + hasCheckableItems(0), sloppyDelayTimer(0), sloppyAction(0), doChildEffects(false) #ifdef QT3_SUPPORT ,emitHighlighted(false) #endif @@ -275,7 +275,7 @@ public: mutable bool hasCheckableItems; //sloppy selection - static int sloppyDelayTimer; + int sloppyDelayTimer; mutable QAction *sloppyAction; QRegion sloppyRegion; -- 2.1.4