mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Don't allow floating point values for rcountmax
This is a better version of the previous commit, which: a) makes the code more readable b) disallows rcountmax values like "6.05", i.e. restricts to integers only.
This commit is contained in:
@@ -2487,10 +2487,13 @@ function UniReader:addAllCommands()
|
||||
local count = NumInputBox:input(G_height-100, 100,
|
||||
"Full refresh after:", self.rcountmax, true)
|
||||
-- convert string to number
|
||||
if pcall(function () count = count + 0 end) then
|
||||
-- restrict self.rcountmax in reasonable range
|
||||
self.rcountmax = math.max(count, 0)
|
||||
self.rcountmax = math.min(self.rcountmax, 10)
|
||||
if pcall(function () count = math.floor(count) end) then
|
||||
if count < 0 then
|
||||
count = 0
|
||||
elseif count > 10 then
|
||||
count = 10
|
||||
end
|
||||
self.rcountmax = count
|
||||
-- storing this parameter in both global and local settings
|
||||
G_reader_settings:saveSetting("rcountmax", self.rcountmax)
|
||||
self.settings:saveSetting("rcountmax", self.rcountmax)
|
||||
|
||||
Reference in New Issue
Block a user