mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-16 07:47:22 +01:00
object: Make the legacy accessor code more robust.
* Using `= one and two or three` is a bad idea on boolean. * Using # to check if a table has content doesn't work on named keys
This commit is contained in:
parent
a065e2e1a9
commit
c96487515f
1 changed files with 7 additions and 5 deletions
|
@ -135,7 +135,7 @@ end
|
|||
--
|
||||
-- TO BE USED FOR DEPRECATION ONLY.
|
||||
|
||||
local function copy_object(obj, to_set, name, capi_name, is_object, join_if, set_empty)
|
||||
local function copy_object(obj, to_set, name, capi_name, is_object, join_if, set_empty)-- luacheck: no unused
|
||||
local ret = gtable.clone(to_set, false)
|
||||
|
||||
-- .buttons used to be a function taking the result of `gears.table.join`.
|
||||
|
@ -148,12 +148,14 @@ local function copy_object(obj, to_set, name, capi_name, is_object, join_if, set
|
|||
-- {deprecated_in=5}
|
||||
-- )
|
||||
|
||||
new_objs, self = is_object and new_objs or self, is_object and self or obj
|
||||
if not is_object then
|
||||
new_objs, self = self, obj
|
||||
end
|
||||
|
||||
local has_content = new_objs and next(new_objs)
|
||||
|
||||
-- Setter
|
||||
if new_objs and #new_objs > 0 then
|
||||
if (not set_empty) and not next(new_objs) then return end
|
||||
|
||||
if new_objs and has_content then
|
||||
local is_formatted = join_if(new_objs)
|
||||
|
||||
-- Because modules may rely on :buttons taking a list of
|
||||
|
|
Loading…
Reference in a new issue