lua: execute idle handlers after timers have been processed

Idle handlers used to not be executed when timers were active
Now they are executed:
* After all expired timers have been executed
* After all events have been processed (same as when there are no timers)
This commit is contained in:
Olivier Perret 2019-01-06 15:01:43 +01:00 committed by sfan5
parent c681fc133c
commit 9be68e49b2
1 changed files with 3 additions and 6 deletions

View File

@ -476,12 +476,9 @@ function mp.dispatch_events(allow_wait)
while mp.keep_running do
local wait = 0
if not more_events then
wait = process_timers()
if wait == nil then
for _, handler in ipairs(idle_handlers) do
handler()
end
wait = 1e20 -- infinity for all practical purposes
wait = process_timers() or 1e20 -- infinity for all practical purposes
for _, handler in ipairs(idle_handlers) do
handler()
end
-- Resume playloop - important especially if an error happened while
-- suspended, and the error was handled, but no resume was done.