From bd47edb4ef692e04a949c39c8a90f552382d589f Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 27 Sep 2015 14:42:39 +0200 Subject: [PATCH] leak test: Make the layoutbox test pass This commit does two things: It gets rid of the reference to the layoutbox that the default config created and it changes the widget dependency cache to not keep widgets alive unnecessarily. Signed-off-by: Uli Schlachter --- lib/wibox/widget/base.lua | 2 +- tests/test-leaks.lua | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/wibox/widget/base.lua b/lib/wibox/widget/base.lua index 26203581f..6dbd05da9 100644 --- a/lib/wibox/widget/base.lua +++ b/lib/wibox/widget/base.lua @@ -18,7 +18,7 @@ local base = {} -- {{{ Caches -- Indexes are widgets, allow them to be garbage-collected -local widget_dependencies = setmetatable({}, { __mode = "k" }) +local widget_dependencies = setmetatable({}, { __mode = "kv" }) -- Get the cache of the given kind for this widget. This returns a gears.cache -- that calls the callback of kind `kind` on the widget. diff --git a/tests/test-leaks.lua b/tests/test-leaks.lua index dd36ab9a7..e91727a80 100644 --- a/tests/test-leaks.lua +++ b/tests/test-leaks.lua @@ -10,6 +10,12 @@ local errors = {} local prepare_for_collect = nil +-- Make the layoutbox in the default config GC'able +mywibox[1].visible = false +mywibox = nil +mylayoutbox = nil +awesome.emit_signal("refresh") + -- Test if some objects can be garbage collected local function collectable(a, b, c, d, e, f, g, h, last) assert(last == nil, "got more arguments than supported")