summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorZhang Hao <zhanghao@uniontech.com>2021-03-24 19:37:04 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-14 03:22:07 +0000
commit22b9e8f8893cc478190af22940b095a02771b3a8 (patch)
tree59f27fdd34ab73124bb13f6716eb496faf5c2f6c /src/widgets/widgets
parent49059a400707b2111c20db266d5e005941c70c8e (diff)
Only scroll QMenu when there is a valid active action
When changing the active action via QMenu::setActiveAction the menu will scroll to the active action, but we were scrolling the menu also when the active action was null, resulting in the menu scrolling back to the top. We fix this by guarding the call to scrollMenu. Fixes: QTBUG-92096 Change-Id: I998f99ddacec32640834d59a907d569fdda458f0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 94e03e506a0e953f72c21c4ca827174a3d1f0d73) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qmenu.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index d704aac525..838a29f39e 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -2228,7 +2228,7 @@ void QMenu::setActiveAction(QAction *act)
{
Q_D(QMenu);
d->setCurrentAction(act, 0);
- if (d->scroll)
+ if (d->scroll && act)
d->scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollCenter);
}