{tag,task}list: Use a weak-valued table
The data table is used to map objects (clients/tags) to the buttons associated with them. This is done so that we don't have to re-create the button objects each time this lists are updated. The problem was that this weak-keyed table was never cleared, because the value had a strong reference to the key (via the button's signal): btn:connect_signal("press", function () b:emit_signal("press", o) end) "o" is the key in the table and btn is reachable from the value. This prevented the garbage collection of the key. Using a weak-keyed and weak-valued table fixes this. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
2134a3c2e9
commit
9114ed1846
|
@ -57,7 +57,7 @@ function new(screen, label, buttons)
|
||||||
["right"] = 0},
|
["right"] = 0},
|
||||||
["bg_resize"] = true
|
["bg_resize"] = true
|
||||||
}
|
}
|
||||||
local data = setmetatable({}, { __mode = 'k' })
|
local data = setmetatable({}, { __mode = 'kv' })
|
||||||
local u = function (s)
|
local u = function (s)
|
||||||
if s == screen then
|
if s == screen then
|
||||||
taglist_update(s, w, label, buttons, data, widgets)
|
taglist_update(s, w, label, buttons, data, widgets)
|
||||||
|
|
|
@ -53,7 +53,7 @@ function new(label, buttons)
|
||||||
bg_resize = true,
|
bg_resize = true,
|
||||||
bg_align = "right"
|
bg_align = "right"
|
||||||
}
|
}
|
||||||
local data = setmetatable({}, { __mode = 'k' })
|
local data = setmetatable({}, { __mode = 'kv' })
|
||||||
local u = function () tasklist_update(w, buttons, label, data, widgets) end
|
local u = function () tasklist_update(w, buttons, label, data, widgets) end
|
||||||
for s = 1, capi.screen.count() do
|
for s = 1, capi.screen.count() do
|
||||||
tag.attached_add_signal(s, "property::selected", u)
|
tag.attached_add_signal(s, "property::selected", u)
|
||||||
|
|
Loading…
Reference in New Issue