summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulian <MyFakeAcc.4@googlemail.com>2017-07-02 13:53:32 +0200
committerwm4 <wm4@nowhere>2017-10-09 20:40:32 +0200
commit783046f5ff1dc392866d4df1140075851919db6a (patch)
tree55f80da9257ba6b4c75444b564924c938260937f
parent21603dd5afedaccaf1f565f5b659b68343ab40db (diff)
downloadmpv-783046f5ff1dc392866d4df1140075851919db6a.tar.bz2
mpv-783046f5ff1dc392866d4df1140075851919db6a.tar.xz
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.
-rw-r--r--player/lua/stats.lua21
1 files changed, 12 insertions, 9 deletions
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()