From 982702fdc15c93f79a5fc417d32ce7cfa1736035 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 26 Oct 2020 12:27:05 +0100 Subject: [PATCH] Statistics: Don't blow up when annotating/highlighting stuff with the plugin loaded, but disabled (#6829) Re #6825 Re #6827 --- plugins/statistics.koplugin/main.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index 2855d4f99..465798822 100644 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -2221,19 +2221,23 @@ function ReaderStatistics:onCloseDocument() end function ReaderStatistics:onAddHighlight() - self.data.highlights = self.data.highlights + 1 - return true + if self.is_enabled then + self.data.highlights = self.data.highlights + 1 + end end function ReaderStatistics:onDelHighlight() - if self.data.highlights > 0 then - self.data.highlights = self.data.highlights - 1 + if self.is_enabled then + if self.data.highlights > 0 then + self.data.highlights = self.data.highlights - 1 + end end - return true end function ReaderStatistics:onAddNote() - self.data.notes = self.data.notes + 1 + if self.is_enabled then + self.data.notes = self.data.notes + 1 + end end -- Triggered by auto_save_settings_interval_minutes