Release v0.1.2 don't error on unknown service type

Fix an error when service.Type is not a field of service_types and the
code attempts to call a nil value.

Turns out that service.Type can be the string "?", probably because
connman has not identified the type yet.
This commit is contained in:
Stefano Mazzucco 2016-10-14 10:25:11 +01:00
parent d26389058f
commit f3e0816c7c
2 changed files with 7 additions and 5 deletions

View File

@ -1,8 +1,8 @@
package = "connman_widget"
version = "0.1.1-1"
version = "0.1.2-1"
source = {
url = "git://github.com/stefano-m/awesome-connman_widget",
tag = "v0.1.1"
tag = "v0.1.2"
}
description = {
summary = "A Connman widget for the Awesome Window Manager",

View File

@ -178,10 +178,12 @@ local function get_status_icon(mgr)
return build_icon_path(icon_statuses.unspecified.idle)
elseif mgr.current_service then
local service = mgr.current_service
return service_types[service.Type](service)
else
return build_icon_path(icon_statuses.unspecified.err)
local f = service_types[service.Type]
if type(f) == "function" then
return f(service)
end
end
return build_icon_path(icon_statuses.unspecified.err)
end
local widget = wibox.widget.imagebox()