From 9114ed18467395e3793f34d0ed5501a1afed0774 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 16 Sep 2010 17:28:50 +0200 Subject: [PATCH] {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 --- lib/awful/widget/taglist.lua.in | 2 +- lib/awful/widget/tasklist.lua.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/awful/widget/taglist.lua.in b/lib/awful/widget/taglist.lua.in index 5b283fc5..b3aceb49 100644 --- a/lib/awful/widget/taglist.lua.in +++ b/lib/awful/widget/taglist.lua.in @@ -57,7 +57,7 @@ function new(screen, label, buttons) ["right"] = 0}, ["bg_resize"] = true } - local data = setmetatable({}, { __mode = 'k' }) + local data = setmetatable({}, { __mode = 'kv' }) local u = function (s) if s == screen then taglist_update(s, w, label, buttons, data, widgets) diff --git a/lib/awful/widget/tasklist.lua.in b/lib/awful/widget/tasklist.lua.in index d67de987..35e7432f 100644 --- a/lib/awful/widget/tasklist.lua.in +++ b/lib/awful/widget/tasklist.lua.in @@ -53,7 +53,7 @@ function new(label, buttons) bg_resize = true, bg_align = "right" } - local data = setmetatable({}, { __mode = 'k' }) + local data = setmetatable({}, { __mode = 'kv' }) local u = function () tasklist_update(w, buttons, label, data, widgets) end for s = 1, capi.screen.count() do tag.attached_add_signal(s, "property::selected", u)