summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-03-28 20:47:31 -0500
committerDudemanguy <random342@airmail.cc>2023-03-29 13:33:57 +0000
commit6e4a76db0862303ae7f0f9fd7bdddff128fbd2f0 (patch)
tree08d50cbfb1b6472fff6f1644cb80c21b798d04a0 /player
parentbdf7b5c3b81033a61e218808a95fd3144f20d993 (diff)
downloadmpv-6e4a76db0862303ae7f0f9fd7bdddff128fbd2f0.tar.bz2
mpv-6e4a76db0862303ae7f0f9fd7bdddff128fbd2f0.tar.xz
auto_profiles: check for non-existent properties
Previously, it just silently didn't do anything which is not very intuitive. Since the lua api returns an error string, check to see if it matches the "property not found" case and print an error message. Additionally, don't add the fake property to the internal cached_properties list or try to observe it. This avoids redundant evaluate calls which will never actually succeed. We do still mark it under watched_properties however. This avoids having to call mp.get_property_native multiple times.
Diffstat (limited to 'player')
-rw-r--r--player/lua/auto_profiles.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/player/lua/auto_profiles.lua b/player/lua/auto_profiles.lua
index f43e6b28f3..55394c2e26 100644
--- a/player/lua/auto_profiles.lua
+++ b/player/lua/auto_profiles.lua
@@ -87,8 +87,13 @@ function get(name, default)
-- Normally, we use the cached value only
if not watched_properties[name] then
watched_properties[name] = true
+ local res, err = mp.get_property_native(name)
+ if err == "property not found" then
+ msg.error("Property '" .. name .. "' was not found.")
+ return default
+ end
+ cached_properties[name] = res
mp.observe_property(name, "native", on_property_change)
- cached_properties[name] = mp.get_property_native(name)
end
-- The first time the property is read we need add it to the
-- properties_to_profiles table, which will be used to mark the profile