From 03fda960415c13892e04707bf82323720fd5fc5c Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 19 Nov 2019 21:06:03 +0100 Subject: [PATCH] [fix] Empty directory path and crash on TextWidget (#5606) --- frontend/apps/filemanager/filemanagerutil.lua | 2 +- frontend/apps/reader/skimtowidget.lua | 4 ++-- frontend/ui/widget/bookstatuswidget.lua | 2 +- plugins/statistics.koplugin/readerprogress.lua | 6 ++++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/apps/filemanager/filemanagerutil.lua b/frontend/apps/filemanager/filemanagerutil.lua index 5691b9581..af93c343e 100644 --- a/frontend/apps/filemanager/filemanagerutil.lua +++ b/frontend/apps/filemanager/filemanagerutil.lua @@ -32,7 +32,7 @@ function filemanagerutil.abbreviate(path) end local len = home_dir:len() local start = path:sub(1, len) - if start == home_dir then + if start == home_dir and path:sub(len+1, len+1) == "/" then return path:sub(len+2) end end diff --git a/frontend/apps/reader/skimtowidget.lua b/frontend/apps/reader/skimtowidget.lua index 0a7b80e98..710dc7d43 100644 --- a/frontend/apps/reader/skimtowidget.lua +++ b/frontend/apps/reader/skimtowidget.lua @@ -185,7 +185,7 @@ function SkimToWidget:init() end, } self.current_page_text = Button:new{ - text = self.curr_page, + text = tostring(self.curr_page), bordersize = 0, margin = self.button_margin, radius = 0, @@ -365,7 +365,7 @@ function SkimToWidget:update() self.curr_page = self.page_count end self.progress_bar.percentage = self.curr_page / self.page_count - self.current_page_text:setText(self.curr_page, self.current_page_text.width) + self.current_page_text:setText(tostring(self.curr_page), self.current_page_text.width) end function SkimToWidget:addOriginToLocationStack(add_current) diff --git a/frontend/ui/widget/bookstatuswidget.lua b/frontend/ui/widget/bookstatuswidget.lua index d48bc6b9e..afca8fb3b 100644 --- a/frontend/ui/widget/bookstatuswidget.lua +++ b/frontend/ui/widget/bookstatuswidget.lua @@ -137,7 +137,7 @@ end function BookStatusWidget:getStatDays() if stats_book.days then - return stats_book.days + return tostring(stats_book.days) else return _("N/A") end diff --git a/plugins/statistics.koplugin/readerprogress.lua b/plugins/statistics.koplugin/readerprogress.lua index a92862379..58272d1fe 100644 --- a/plugins/statistics.koplugin/readerprogress.lua +++ b/plugins/statistics.koplugin/readerprogress.lua @@ -40,6 +40,8 @@ local dayOfWeekTranslation = { } function ReaderProgress:init() + self.current_pages = tostring(self.current_pages) + self.today_pages = tostring(self.today_pages) self.small_font_face = Font:getFace("smallffont") self.medium_font_face = Font:getFace("ffont") self.large_font_face = Font:getFace("largeffont") @@ -456,7 +458,7 @@ function ReaderProgress:genSummaryWeek(width) CenterContainer:new{ dimen = Geom:new{ w = tile_width, h = tile_height }, TextWidget:new{ - text = total_pages, + text = tostring(total_pages), face = self.medium_font_face, }, }, @@ -470,7 +472,7 @@ function ReaderProgress:genSummaryWeek(width) CenterContainer:new{ dimen = Geom:new{ w = tile_width, h = tile_height }, TextWidget:new{ - text = math.floor(total_pages / 7), + text = tostring(math.floor(total_pages / 7)), face = self.medium_font_face, } },