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:
Tigran Aivazian
2012-09-30 18:28:10 +01:00
parent 79c1dd44ca
commit 72f669ff3c

View File

@@ -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)