diff --git a/lib/awful/widget/common.lua.in b/lib/awful/widget/common.lua.in index 71be953d5..9373b7acd 100644 --- a/lib/awful/widget/common.lua.in +++ b/lib/awful/widget/common.lua.in @@ -73,8 +73,12 @@ function common.list_update(w, buttons, label, data, template, objects) end if buttons then - if not data[o] then - data[o] = { } + -- Use a local variable so that the garbage collector doesn't strike + -- between now and the :buttons() call. + local btns = data[o] + if not btns then + btns = {} + data[o] = btns for kb, b in ipairs(buttons) do -- Create a proxy button object: it will receive the real -- press and release events, and will propagate them the the @@ -83,11 +87,11 @@ function common.list_update(w, buttons, label, data, template, objects) local btn = capi.button { modifiers = b.modifiers, button = b.button } btn:connect_signal("press", function () b:emit_signal("press", o) end) btn:connect_signal("release", function () b:emit_signal("release", o) end) - data[o][#data[o] + 1] = btn + btns[#btns + 1] = btn end end - ib:buttons(data[o]) - tb:buttons(data[o]) + ib:buttons(btns) + tb:buttons(btns) end local text, bg, bg_image, icon = label(o)