From cf643c453bcbbef0d7986c625112d708558d5471 Mon Sep 17 00:00:00 2001 From: Roygbyte <82218266+roygbyte@users.noreply.github.com> Date: Sat, 29 Oct 2022 21:05:27 -0300 Subject: [PATCH] KeyValuePage: Handle nil/empty kvp arrays (#9705) --- frontend/ui/widget/keyvaluepage.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/ui/widget/keyvaluepage.lua b/frontend/ui/widget/keyvaluepage.lua index f86e61010..66de4269f 100644 --- a/frontend/ui/widget/keyvaluepage.lua +++ b/frontend/ui/widget/keyvaluepage.lua @@ -291,6 +291,7 @@ local KeyValuePage = FocusManager:extend{ } function KeyValuePage:init() + self.kv_pairs = self.kv_pairs or {} self.dimen = Geom:new{ x = 0, y = 0, @@ -594,7 +595,8 @@ function KeyValuePage:_populateItems() local unfit_items_count -- count item that needs to move or truncate key/value, not fit 1/2 ratio -- first we check if no unfit item at all local width_ratio - if key_widths[#key_widths] <= key_w and value_widths[#value_widths] <= value_w then + if (#self.kv_pairs == 0) or + (key_widths[#key_widths] <= key_w and value_widths[#value_widths] <= value_w) then width_ratio = 1/2 end if not width_ratio then