Skip to content

Commit

Permalink
fix: crash when a script menu update renders selected index unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-heinrich authored and po5 committed Jul 26, 2023
1 parent 72982e2 commit 02a934e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/uosc/elements/Menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ function Menu:update(data)
local old_menu = self.by_id[menu.is_root and '__root__' or menu.id]
if old_menu then table_assign(menu, old_menu, {'selected_index', 'scroll_y', 'fling'}) end

if menu.selected_index then
menu.selected_index = clamp(1, menu.selected_index, #menu.items)
end

new_all[#new_all + 1] = menu
new_by_id[menu.is_root and '__root__' or menu.id] = menu
end
Expand Down

0 comments on commit 02a934e

Please sign in to comment.