From 5039c24ed013bed9d683505a7315f6b954e6b8b4 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 8 May 2009 14:36:39 +0200 Subject: [PATCH] ta{g,sk}list: fix memory leak on removal Signed-off-by: Julien Danjou --- lib/awful/widget/taglist.lua.in | 5 +++++ lib/awful/widget/tasklist.lua.in | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/lib/awful/widget/taglist.lua.in b/lib/awful/widget/taglist.lua.in index 0a631bccd..128784e10 100644 --- a/lib/awful/widget/taglist.lua.in +++ b/lib/awful/widget/taglist.lua.in @@ -67,6 +67,11 @@ function new(screen, label, buttons) end end) u(screen) + -- Free data on tag removal. + -- See tasklist to get why this is needed. + hooks.tags.register(function (s, tag, action) + if action == "remove" then data[tag] = nil end + end) return w end diff --git a/lib/awful/widget/tasklist.lua.in b/lib/awful/widget/tasklist.lua.in index 514399ad8..a6070aea8 100644 --- a/lib/awful/widget/tasklist.lua.in +++ b/lib/awful/widget/tasklist.lua.in @@ -70,6 +70,13 @@ function new(label, buttons) end end) u() + -- Free data on unmanage. + -- You may thing we do not need to clear data[] on unmanage because it's a + -- weak-keyed table. But in fact we need, because it's a loop reference + -- between data[client] and data[client][i] = button(reference a client in + -- the Lua registry) and since the registry and the button() are totally + -- unconnected, Lua does not free anything. + hooks.unmanage.register(function (c) data[c] = nil end) return w end