Avoid crash in menu that was previously shown as submenu

Reset sloppyState for the previous submenu, so that if it
will be shown as a menu, it will not use an incorrect pointer.

Fixes: QTBUG-80528
Change-Id: If2ba8c3a664983ee76eb90d2c9a8096e2bd0a4e6
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 8339ce2155752eb8fa0f49f3fe4b24f9643ae463)
This commit is contained in:
Alexander Volkov 2019-12-03 17:34:06 +03:00
parent d96bbd999f
commit 7110eb7ca1

View File

@ -791,6 +791,8 @@ void QMenuSloppyState::setSubMenuPopup(const QRect &actionRect, QAction *resetAc
m_use_reset_action = true;
m_time.stop();
m_action_rect = actionRect;
if (m_sub_menu)
QMenuPrivate::get(m_sub_menu)->sloppyState.m_parent = nullptr;
m_sub_menu = subMenu;
QMenuPrivate::get(subMenu)->sloppyState.m_parent = this;
m_reset_action = resetAction;