From 9e79d187477529812b6f6578fa88e1633874074b Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 7 Oct 2010 18:42:05 +0200 Subject: [PATCH] Tasklist: Fail less badly with invalid utf8 xterm is famous for messing up the utf8 in its title (unless correctly configured). Signed-off-by: Uli Schlachter --- lib/awful/widget/common.lua.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/awful/widget/common.lua.in b/lib/awful/widget/common.lua.in index 6f5716480..689f70ace 100644 --- a/lib/awful/widget/common.lua.in +++ b/lib/awful/widget/common.lua.in @@ -7,6 +7,7 @@ -- Grab environment we need local math = math local type = type +local pcall = pcall local ipairs = ipairs local setmetatable = setmetatable local capi = { widget = widget, button = button } @@ -73,7 +74,13 @@ function list_update(w, buttons, label, data, widgets, objects) end local text, bg, bg_image, icon = label(o) - w[k + 1].text, w[k + 1].bg, w[k + 1].bg_image = text, bg, bg_image + + -- Check if we got a valid text here, it might contain e.g. broken utf8. + if not pcall(function() w[k + 1].text = text end) then + w[k + 1].text = "Invalid" + end + + w[k + 1].bg, w[k + 1].bg_image = bg, bg_image w[k].bg, w[k].image = bg, icon if not w[k + 1].text then w[k+1].visible = false