From 83172d62ae10274d369273484616549331bcf2e4 Mon Sep 17 00:00:00 2001 From: poire-z Date: Mon, 31 Jan 2022 19:18:40 +0100 Subject: [PATCH] ReaderStatistics: reset stack/link on showing first widget Reset self.kv stack/link on showing first widget. This avoids return arrow to possibly show previously displayed old and unrelated KeyValuePage. Note: when closing a leaf KeyValuePage, the previous one will leak as self.kv. --- plugins/statistics.koplugin/main.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index 1b07e02ca..e91c1103b 100644 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -1056,10 +1056,11 @@ The max value ensures a page you stay on for a long time (because you fell aslee text = _("Current book"), keep_menu_open = true, callback = function() - UIManager:show(KeyValuePage:new{ + self.kv = KeyValuePage:new{ title = _("Current statistics"), kv_pairs = self:getCurrentStat() - }) + } + UIManager:show(self.kv) end, enabled_func = function() return not self:isDocless() and self.settings.is_enabled end, }, @@ -2448,6 +2449,7 @@ end function ReaderStatistics:onShowCalendarView() self:insertDB() + self.kv = nil -- clean left over stack link local CalendarView = require("calendarview") UIManager:show(CalendarView:new{ reader_statistics = self, @@ -2569,11 +2571,11 @@ end function ReaderStatistics:onShowBookStats() if self:isDocless() or not self.settings.is_enabled then return end - local stats = KeyValuePage:new{ + self.kv = KeyValuePage:new{ title = _("Current statistics"), kv_pairs = self:getCurrentStat() } - UIManager:show(stats) + UIManager:show(self.kv) end function ReaderStatistics:getCurrentBookReadPages()