2
0
mirror of https://github.com/koreader/koreader synced 2024-11-04 12:00:25 +00:00

NaturalLightWidget: Fallback to previous values instead of nil (#10425)

Happens in case the InputText field is emptied by the user.
The backend code makes rather strong assumptions that it'll *always* get a number of of it ;).

Fix #10352
This commit is contained in:
NiLuJe 2023-05-13 20:45:47 +02:00 committed by GitHub
parent 5c353c2289
commit b989a6ff15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,6 +115,13 @@ function NaturalLightWidget:adaptableNumber(initial, step)
table.insert(minus_number_plus, button_minus)
table.insert(minus_number_plus, input_text)
table.insert(minus_number_plus, button_plus)
-- Sanitize the returned value so as not to upset sysfs_light...
function input_text:getText()
-- Also, while we're here, make sure we actually return a number, because InputText doesn't for... reasons.
return tonumber(self.text) or initial
end
return minus_number_plus
end