Fix crash on exit on Kobo devices with no frontlight (#3221)

pull/3222/head
poire-z 7 years ago committed by Frans de Jonge
parent 7c88bad189
commit 0122c086f2

@ -87,28 +87,30 @@ function KoboPowerD:init()
end end
function KoboPowerD:saveSettings() function KoboPowerD:saveSettings()
-- Store BasePowerD values into settings (and not our hw_intensity, so if self.device.hasFrontlight() then
-- that if frontlight was toggled off, we save and restore the previous -- Store BasePowerD values into settings (and not our hw_intensity, so
-- untoggled intensity and toggle state at next startup) -- that if frontlight was toggled off, we save and restore the previous
local cur_intensity = self.fl_intensity -- untoggled intensity and toggle state at next startup)
local cur_is_fl_on = self.is_fl_on local cur_intensity = self.fl_intensity
-- Save intensity to koreader settings local cur_is_fl_on = self.is_fl_on
G_reader_settings:saveSetting("frontlight_intensity", cur_intensity) -- Save intensity to koreader settings
G_reader_settings:saveSetting("is_frontlight_on", cur_is_fl_on) G_reader_settings:saveSetting("frontlight_intensity", cur_intensity)
-- And to "Kobo eReader.conf" if needed G_reader_settings:saveSetting("is_frontlight_on", cur_is_fl_on)
if KOBO_SYNC_BRIGHTNESS_WITH_NICKEL then -- And to "Kobo eReader.conf" if needed
if NickelConf.frontLightState.get() ~= nil then if KOBO_SYNC_BRIGHTNESS_WITH_NICKEL then
if NickelConf.frontLightState.get() ~= cur_is_fl_on then if NickelConf.frontLightState.get() ~= nil then
NickelConf.frontLightState.set(cur_is_fl_on) if NickelConf.frontLightState.get() ~= cur_is_fl_on then
NickelConf.frontLightState.set(cur_is_fl_on)
end
else -- no support for frontlight state
if not cur_is_fl_on then -- if toggled off, save intensity as 0
cur_intensity = self.fl_min
end
end end
else -- no support for frontlight state if NickelConf.frontLightLevel.get() ~= cur_intensity then
if not cur_is_fl_on then -- if toggled off, save intensity as 0 NickelConf.frontLightLevel.set(cur_intensity)
cur_intensity = self.fl_min
end end
end end
if NickelConf.frontLightLevel.get() ~= cur_intensity then
NickelConf.frontLightLevel.set(cur_intensity)
end
end end
end end

Loading…
Cancel
Save