diff options
author | Guido Cella <guido@guidocella.xyz> | 2024-01-14 08:00:08 +0100 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2024-01-20 16:09:34 +0000 |
commit | de0849404b65876f0f8fe934c4b74f497bf4e29b (patch) | |
tree | d1d8d91b08efa1d88e8b5697f5e8b088012a0404 /TOOLS | |
parent | c209d4f73bc69778a31cf1db975379be91a7f26b (diff) | |
download | mpv-de0849404b65876f0f8fe934c4b74f497bf4e29b.tar.bz2 mpv-de0849404b65876f0f8fe934c4b74f497bf4e29b.tar.xz |
scripting: don't observe properties with type nil
mp.observe_property('foo', nil, ...) calls the handler at least 2 times
on each playlist change even when the property doesn't change. This is
dangerous because if you haven't read observe_property's documentation
in a long time this is easy to forget, and you can end up using it for
handlers that are computationally expensive or that cause unintended
side effects.
Therefore, this commit discourages its use more explicitly in the
documentation, and replaces its usages in scripts.
For console.lua, observing focused with type nil leads to calling
mp.osd_message('') when changing file while playing in the terminal with
the console disabled. I don't notice issues from this, but it's safer to
avoid it.
For playlist and track-list this doesn't really matter since they
trigger multiple changes on each new file anyway, but changing it can
avoid encouraging people to imitate the code.
One usage of none in stats.lua is kept because according to b9084dfd47
it is a hack to replicate the deprecated tick event.
Diffstat (limited to 'TOOLS')
-rw-r--r-- | TOOLS/lua/skip-logo.lua | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/TOOLS/lua/skip-logo.lua b/TOOLS/lua/skip-logo.lua index 8e1f9da489..ae66b22250 100644 --- a/TOOLS/lua/skip-logo.lua +++ b/TOOLS/lua/skip-logo.lua @@ -232,7 +232,7 @@ local function read_frames() end end -mp.observe_property(meta_property, "none", function() +mp.observe_property(meta_property, "native", function() -- Ignore frames that are decoded/filtered during seeking. if seeking then return |