From 97b81a7eb652a0619f8e5db462bcd879231d2d31 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Thu, 15 Apr 2021 02:46:44 +0200 Subject: [PATCH] Menu: Don't share the `dimen` object across Menu instances (!) The object was never re-assigned, so closing a smaller menu (e.g., Calibre metadata search) made the underlying one (e.g., CoverBrowser's ListMenu) inherit the smaller dimensions... Instead of creating the object in the Class constructor, create it in the instance constructor (i.e., :init). Similar cleanups in other Menu* related classes. --- frontend/ui/widget/menu.lua | 10 +++++----- frontend/ui/widget/sortwidget.lua | 2 +- frontend/ui/widget/touchmenu.lua | 2 +- plugins/calibre.koplugin/search.lua | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/ui/widget/menu.lua b/frontend/ui/widget/menu.lua index 6b64e8249..89aea9673 100644 --- a/frontend/ui/widget/menu.lua +++ b/frontend/ui/widget/menu.lua @@ -88,7 +88,7 @@ local MenuCloseButton = InputContainer:new{ overlap_align = "right", padding_right = 0, menu = nil, - dimen = Geom:new{}, + dimen = nil, } function MenuCloseButton:init() @@ -544,8 +544,8 @@ local Menu = FocusManager:new{ -- height will be calculated according to item number if not given height = nil, header_padding = Size.padding.large, - dimen = Geom:new{}, - item_table = {}, + dimen = nil, + item_table = nil, -- NOT mandatory (will be empty) item_shortcuts = { "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Del", @@ -605,9 +605,9 @@ end function Menu:init() self.show_parent = self.show_parent or self + self.item_table = self.item_table or {} self.item_table_stack = {} - self.dimen.w = self.width - self.dimen.h = self.height or Screen:getHeight() + self.dimen = Geom:new{ w = self.width, h = self.height or Screen:getHeight() } if self.dimen.h > Screen:getHeight() or self.dimen.h == nil then self.dimen.h = Screen:getHeight() end diff --git a/frontend/ui/widget/sortwidget.lua b/frontend/ui/widget/sortwidget.lua index 30288e524..f822ac7a4 100644 --- a/frontend/ui/widget/sortwidget.lua +++ b/frontend/ui/widget/sortwidget.lua @@ -149,7 +149,7 @@ local SortWidget = InputContainer:new{ -- index for the first item to show show_page = 1, -- table of items to sort - item_table = {}, + item_table = nil, -- mandatory callback = nil, } diff --git a/frontend/ui/widget/touchmenu.lua b/frontend/ui/widget/touchmenu.lua index 541d67ff5..01186215d 100644 --- a/frontend/ui/widget/touchmenu.lua +++ b/frontend/ui/widget/touchmenu.lua @@ -417,7 +417,7 @@ end TouchMenu widget for hierarchical menus --]] local TouchMenu = FocusManager:new{ - tab_item_table = {}, + tab_item_table = nil, -- mandatory -- for returning in multi-level menus item_table_stack = nil, item_table = nil, diff --git a/plugins/calibre.koplugin/search.lua b/plugins/calibre.koplugin/search.lua index d9b6e24f3..bd0c9c7cf 100644 --- a/plugins/calibre.koplugin/search.lua +++ b/plugins/calibre.koplugin/search.lua @@ -331,7 +331,7 @@ function CalibreSearch:find(option) local result = self:bookCatalog(books) self:showresults(result) else - self:browse(option,1) + self:browse(option, 1) end logger.info(string.format("search done in %.3f milliseconds (%s, %s, %s, %s, %s)", (TimeVal:now() - start):tomsecs(),