mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Fix duplicate suspend scheduling in Device:onPowerEvent
We should always unschedule suspend before scheduling it again (i.e., use rescheduleSuspend ;)). Fix #8097 (many thanks to @Mel-kior for the detailed repro!)
This commit is contained in:
@@ -341,7 +341,7 @@ function Device:onPowerEvent(ev)
|
||||
-- Only actually schedule suspension if we're still supposed to go to sleep,
|
||||
-- because the Wi-Fi stuff above may have blocked for a significant amount of time...
|
||||
if self.screen_saver_mode then
|
||||
UIManager:scheduleIn(self.suspend_wait_timeout, self.suspend)
|
||||
self:rescheduleSuspend()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -1178,16 +1178,15 @@ function UIManager:_checkTasks()
|
||||
-- task.action may schedule other events
|
||||
self._task_queue_dirty = false
|
||||
while true do
|
||||
local nu_task = #self._task_queue
|
||||
if nu_task == 0 then
|
||||
-- all tasks checked
|
||||
if #self._task_queue == 0 then
|
||||
-- Nothing to do!
|
||||
break
|
||||
end
|
||||
local task = self._task_queue[1]
|
||||
local task_tv = task.time or TimeVal.zero
|
||||
local next_task = self._task_queue[1]
|
||||
local task_tv = next_task.time or TimeVal.zero
|
||||
if task_tv <= self._now then
|
||||
-- remove from table
|
||||
table.remove(self._task_queue, 1)
|
||||
local task = table.remove(self._task_queue, 1)
|
||||
-- task is pending to be executed right now. do it.
|
||||
-- NOTE: be careful that task.action() might modify
|
||||
-- _task_queue here. So need to avoid race condition
|
||||
@@ -1195,7 +1194,7 @@ function UIManager:_checkTasks()
|
||||
else
|
||||
-- queue is sorted in ascendant order, safe to assume all items
|
||||
-- are future tasks for now
|
||||
wait_until = task.time
|
||||
wait_until = next_task.time
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user