1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-25 04:38:01 +00:00

stats: resilience against accidential timer removal

Previously I could trigger a bug with intense button mashing, however,
was unable to reproduce it and therefore debug it.
This change now seems to be resilient against button mashing, let's hope
it really is.
This commit is contained in:
Julian 2017-07-02 13:53:32 +02:00 committed by wm4
parent 21603dd5af
commit 783046f5ff

View File

@ -540,9 +540,13 @@ end
local function add_page_bindings()
local function a(k)
return function()
-- In single invocation case we need to reset the timer because
-- stats are printed again for o.duration
if not toggle_timer:is_enabled() then
binding_timer:kill()
binding_timer:resume()
end
curr_page = k
binding_timer:kill()
binding_timer:resume()
print_page(k, toggle_timer:is_enabled() and o.redraw_delay + 1 or nil)
end
end
@ -595,12 +599,6 @@ end
local function toggle_stats()
-- In case stats are toggled while oneshot-stats are still visible the
-- oneshot-stats will remove our keybindings
if binding_timer:is_enabled() then
binding_timer:kill()
end
-- Disable
if toggle_timer:is_enabled() then
if recorder then
@ -649,7 +647,12 @@ toggle_timer = mp.add_periodic_timer(o.redraw_delay, function() print_page(curr_
toggle_timer:kill()
-- Create timer used to remove forced key bindings, only in the "single invocation" case
binding_timer = mp.add_periodic_timer(o.duration, function() remove_page_bindings() end)
binding_timer = mp.add_periodic_timer(o.duration,
function()
if not toggle_timer:is_enabled() then
remove_page_bindings()
end
end)
binding_timer.oneshot = true
binding_timer:kill()