From 783046f5ff1dc392866d4df1140075851919db6a Mon Sep 17 00:00:00 2001 From: Julian Date: Sun, 2 Jul 2017 13:53:32 +0200 Subject: 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. --- player/lua/stats.lua | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'player') diff --git a/player/lua/stats.lua b/player/lua/stats.lua index c0ec4715ea..fd3ec19c00 100644 --- a/player/lua/stats.lua +++ b/player/lua/stats.lua @@ -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() -- cgit v1.2.3