Fix menu crash when quickly repeatedly opening and closing submenu

Opening and closing a submenu very quickly very quickly
(smashing right and left arrow as fast as I possibly can)
resulted in a nil error.
This commit is contained in:
Christoph Heinrich
2022-07-30 00:14:09 +02:00
committed by Tomas Klaen
parent 3cff450016
commit 3466ea5299

View File

@@ -1075,7 +1075,7 @@ function Menu:open(items, open_item, opts)
elements:add('menu', transition_target)
end
menu.transition = nil
transition_target:back()
if transition_target then transition_target:back() end
return
else
menu.transition = {to = 'parent', target = this.parent_menu}
@@ -1107,7 +1107,7 @@ function Menu:open(items, open_item, opts)
local target = menu.transition.target
tween_element_stop(target)
menu.transition = nil
target:open_selected_item(soft)
if target then target:open_selected_item(soft) end
return
end