From e917b699a9747d557a4f8ad1dd73661573a8d9a8 Mon Sep 17 00:00:00 2001 From: Stefano Mazzucco Date: Wed, 14 Jun 2017 22:35:16 +0100 Subject: [PATCH] Check that the services array is not nil before indexing it This may happen when e.g. the connman service is restarted. --- connman_widget.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/connman_widget.lua b/connman_widget.lua index 097e447..d31e801 100644 --- a/connman_widget.lua +++ b/connman_widget.lua @@ -229,7 +229,12 @@ cdbus.connect_signal( -- "addded" should be a list of {object_path, properties_table} pairs, -- but the Awesome API returns nil instead of an object_path -- so we're forced to update all the services. - current_service = connman:GetServices()[1] + local services = connman:GetServices() + if services then + current_service = services[1] + else + current_service = nil + end widget:update() elseif info.member == "PropertyChanged" then local name, value = unpack({...})