2015-09-27 12:25:20 +02:00
|
|
|
-- Some memory leak checks as integration tests.
|
|
|
|
|
|
|
|
local awful = require("awful")
|
|
|
|
local cairo = require("lgi").cairo
|
|
|
|
local create_wibox = require("_wibox_helper").create_wibox
|
|
|
|
local gears = require("gears")
|
|
|
|
local wibox = require("wibox")
|
|
|
|
|
|
|
|
local errors = {}
|
|
|
|
|
|
|
|
local prepare_for_collect = nil
|
|
|
|
|
|
|
|
-- Test if some objects can be garbage collected
|
2015-09-27 14:10:45 +02:00
|
|
|
local function collectable(a, b, c, d, e, f, g, h, last)
|
|
|
|
assert(last == nil, "got more arguments than supported")
|
2015-09-27 12:25:20 +02:00
|
|
|
local objs = setmetatable({ a, b, c, d, e, f, g, h }, { __mode = "v" })
|
|
|
|
a, b, c, d, e, f, g, h = nil, nil, nil, nil, nil, nil, nil, nil
|
|
|
|
if prepare_for_collect then
|
|
|
|
prepare_for_collect()
|
|
|
|
prepare_for_collect = nil
|
|
|
|
end
|
|
|
|
collectgarbage("collect")
|
|
|
|
-- Check if the table is now empty
|
|
|
|
for k, v in pairs(objs) do
|
|
|
|
print("Some object was not garbage collected!")
|
|
|
|
error(v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- First test some basic widgets
|
|
|
|
collectable(wibox.widget.base.make_widget())
|
|
|
|
collectable(wibox.widget.textbox("foo"))
|
|
|
|
collectable(wibox.layout.fixed.horizontal())
|
|
|
|
collectable(wibox.layout.align.horizontal())
|
|
|
|
|
|
|
|
-- Then some random widgets from awful
|
|
|
|
collectable(awful.widget.launcher({ image = cairo.ImageSurface(cairo.Format.ARGB32, 20, 20), command = "bash" }))
|
|
|
|
collectable(awful.widget.prompt())
|
|
|
|
collectable(awful.widget.textclock())
|
|
|
|
collectable(awful.widget.layoutbox(1))
|
2015-09-27 14:10:45 +02:00
|
|
|
|
2015-09-27 14:03:59 +02:00
|
|
|
function prepare_for_collect()
|
|
|
|
-- Only after doing the pending update can a taglist be GC'd.
|
|
|
|
awesome.emit_signal("refresh")
|
|
|
|
end
|
2015-09-27 12:25:20 +02:00
|
|
|
collectable(awful.widget.taglist(1, awful.widget.taglist.filter.all))
|
|
|
|
|
2015-09-27 14:10:45 +02:00
|
|
|
function prepare_for_collect()
|
|
|
|
-- Only after doing the pending update can a taglist be GC'd.
|
|
|
|
awesome.emit_signal("refresh")
|
|
|
|
end
|
|
|
|
collectable(awful.widget.tasklist(1, awful.widget.tasklist.filter.currenttags))
|
|
|
|
|
2015-09-27 12:25:20 +02:00
|
|
|
-- And finally a full wibox
|
|
|
|
function prepare_for_collect()
|
|
|
|
-- Only after doing the pending repaint can a wibox be GC'd.
|
|
|
|
awesome.emit_signal("refresh")
|
|
|
|
end
|
|
|
|
collectable(create_wibox())
|
|
|
|
|
|
|
|
require("_runner").run_steps({ function() return true end })
|