awful.widget: fix iteration over removed elements

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Michael Hofmann 2008-11-27 11:20:25 +01:00 committed by Julien Danjou
parent 5fecdc052d
commit 3cc7843f05
1 changed files with 5 additions and 3 deletions

View File

@ -164,12 +164,14 @@ function tasklist.new(label, buttons)
local w = {}
local function tasklist_update ()
local clients = capi.client.get()
local shownclients = {}
for k, c in ipairs(clients) do
if c.skip_taskbar or c.hide
or c.type == "splash" or c.type == "dock" or c.type == "desktop" then
table.remove(clients, k)
if not (c.skip_taskbar or c.hide
or c.type == "splash" or c.type == "dock" or c.type == "desktop") then
table.insert(shownclients, c)
end
end
clients = shownclients
-- Hack: if it has been registered as a widget in a wibox,
-- it's w.len since __len meta does not work on table until Lua 5.2.
-- Otherwise it's standard #w.