diff --git a/frontend/device/wakeupmgr.lua b/frontend/device/wakeupmgr.lua index 46dc43c6a..724864cdb 100644 --- a/frontend/device/wakeupmgr.lua +++ b/frontend/device/wakeupmgr.lua @@ -88,7 +88,7 @@ with anonymous functions. @treturn bool (true if one or more tasks were removed; false otherwise; nil if the task queue is empty). --]] function WakeupMgr:removeTasks(epoch, callback) - if #self._task_queue < 1 then return end + if #self._task_queue == 0 then return end local removed = false local reschedule = false @@ -147,7 +147,7 @@ If necessary, the next upcoming task (if any) is scheduled on exit. @treturn bool (true if we were truly woken up by the scheduled wakeup; false otherwise; nil if there weren't any tasks scheduled). --]] function WakeupMgr:wakeupAction(proximity) - if #self._task_queue > 0 then + if self._task_queue[1] then local task = self._task_queue[1] if self:validateWakeupAlarmByProximity(task.epoch, proximity) then task.callback() diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index 86507ecd7..57c5d8a97 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -1142,7 +1142,7 @@ end --]] function UIManager:getNextTaskTime() - if #self._task_queue > 0 then + if self._task_queue[1] then return self._task_queue[1].time - time:now() else return nil @@ -1156,10 +1156,12 @@ function UIManager:_checkTasks() -- task.action may schedule other events self._task_queue_dirty = false while true do - if #self._task_queue == 0 then + if not self._task_queue[1] then -- Nothing to do! break end + -- FIXME: Err, the or makes no sense, UIManager:schedule should ensure time & action fields are sane? + -- Either check nothing, or check both time *and* action (which should *never* be nil, unless Greminls, c.f., #9112) local task_time = self._task_queue[1].time or 0 if task_time <= self._now then -- remove from table