From 0a4fb89239864dbf9e76ba4f5f28967706cd01aa Mon Sep 17 00:00:00 2001 From: poire-z Date: Thu, 15 Mar 2018 15:39:44 +0100 Subject: [PATCH] Fix possible crash with config panel when engine switched (#3761) Reading an epub file with Mupdf would show 6 items in bottom config panel. Reading it with crengine would show only 5. A crash would happen if we were on the 6th when leaving MuPDF, and later opening config panel with crengine. --- frontend/apps/reader/modules/readerconfig.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/apps/reader/modules/readerconfig.lua b/frontend/apps/reader/modules/readerconfig.lua index 5a57f274d..8ed725c3a 100644 --- a/frontend/apps/reader/modules/readerconfig.lua +++ b/frontend/apps/reader/modules/readerconfig.lua @@ -118,7 +118,11 @@ end function ReaderConfig:onReadSettings(config) self.configurable:loadSettings(config, self.options.prefix.."_") - self.last_panel_index = config:readSetting("config_panel_index") or 1 + local config_panel_index = config:readSetting("config_panel_index") + if config_panel_index then + config_panel_index = math.min(config_panel_index, #self.options) + end + self.last_panel_index = config_panel_index or 1 end function ReaderConfig:onSaveSettings()