{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
3aee846869
commit
89f05c90ca
|
@ -158,7 +158,7 @@ function new(screen, filter, buttons, style, template)
|
||||||
layout = layout.horizontal.leftright
|
layout = layout.horizontal.leftright
|
||||||
}
|
}
|
||||||
|
|
||||||
local data = setmetatable({}, { __mode = 'k' })
|
local data = setmetatable({}, { __mode = 'vk' })
|
||||||
local u = function (s)
|
local u = function (s)
|
||||||
if s == screen then
|
if s == screen then
|
||||||
taglist_update(s, w, buttons, filter, data, style, template)
|
taglist_update(s, w, buttons, filter, data, style, template)
|
||||||
|
|
|
@ -133,7 +133,7 @@ function new(screen, filter, buttons, style, template)
|
||||||
layout = layout.horizontal.leftright
|
layout = layout.horizontal.leftright
|
||||||
}
|
}
|
||||||
|
|
||||||
local data = setmetatable({}, { __mode = 'k' })
|
local data = setmetatable({}, { __mode = 'kv' })
|
||||||
local u = function () tasklist_update(screen, w, buttons, filter, data, style, template) end
|
local u = function () tasklist_update(screen, w, buttons, filter, data, style, template) end
|
||||||
capi.screen[screen]:connect_signal("tag::detach", u)
|
capi.screen[screen]:connect_signal("tag::detach", u)
|
||||||
tag.attached_connect_signal(screen, "property::selected", u)
|
tag.attached_connect_signal(screen, "property::selected", u)
|
||||||
|
|
Loading…
Reference in New Issue