From e888d983efcb3881bf864b8161f6f25b76f41e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Lepage=20Vall=C3=A9e?= Date: Wed, 9 Oct 2019 13:35:05 -0400 Subject: [PATCH] legacy: Temporary workaround for #2897. (#2898) The `:keys()` and `:buttons()` APIs moved from get/set single methods to properties. It works fine if you use the new or old API, but has limitations when mixing them. `awful.rules` calls properties in a loop after checking if it is a function. Thus it triggers the secondary codepath to try to handle this case. This codepath was tested with gears.objects based components (ie. widgets). It was not tested with clients and tags, and it didn't work because they use `awful.tag.getproperty` and `awful.client.property.get` instead of `._private` like all newer components. Those old functions are officially deprecated, but used by tons of configs and modules ported from v3.5 and thus still the default way to access Lua properties in our implementation. This commit adds a `_private` to anything that doesn't have one to at least make the error stop. It will "mostly" work until a more complete solution is added. Reverting the 2 PRs that changed this would delay getting more feedbacks. --- lib/gears/object/properties.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/gears/object/properties.lua b/lib/gears/object/properties.lua index 8f29ee018..19ab239bb 100644 --- a/lib/gears/object/properties.lua +++ b/lib/gears/object/properties.lua @@ -161,10 +161,16 @@ function object._legacy_accessors(obj, name, capi_name, is_object, join_if, set_ magic_obj["get_"..name] = function(self) self = is_object and self or obj + --FIXME v5 all objects should use _private instead of getproperty. + if not self._private then + self._private = {} + end + self._private[name] = self._private[name] or copy_object( obj, {}, name, capi_name, is_object, join_if, set_empty ) + assert(self._private[name]) return self._private[name] end