summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Matos <tiagomatos@gmail.com>2017-11-01 16:45:46 +0100
committerRui Matos <tiagomatos@gmail.com>2017-11-01 16:47:36 +0100
commitcb4a7e17735029f5747714c2faf80e7d4d30474b (patch)
tree67bbadb7b8cd38e81bb96ac9d4992285d39a6761
parent6723ff4d2b3c4154414abbe8350cc7950fa8f914 (diff)
downloadgnome-control-center-cb4a7e17735029f5747714c2faf80e7d4d30474b.tar.gz
network: Avoid crashing if NM reports no devices or no connections
Seems like NM changed behavior recently but, in any case, better safe than sorry. https://bugzilla.gnome.org/show_bug.cgi?id=788716
-rw-r--r--panels/network/cc-network-panel.c6
-rw-r--r--panels/network/cc-wifi-panel.c7
2 files changed, 9 insertions, 4 deletions
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index c33cef1d5..51ea823f7 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -915,8 +915,10 @@ cc_network_panel_init (CcNetworkPanel *panel)
/* Cold-plug existing connections */
connections = nm_client_get_connections (panel->client);
- for (i = 0; i < connections->len; i++)
- add_connection (panel, connections->pdata[i]);
+ if (connections) {
+ for (i = 0; i < connections->len; i++)
+ add_connection (panel, connections->pdata[i]);
+ }
g_debug ("Calling handle_argv() after cold-plugging connections");
handle_argv (panel);
diff --git a/panels/network/cc-wifi-panel.c b/panels/network/cc-wifi-panel.c
index 38e65bba5..4407ba7b2 100644
--- a/panels/network/cc-wifi-panel.c
+++ b/panels/network/cc-wifi-panel.c
@@ -141,8 +141,11 @@ load_wifi_devices (CcWifiPanel *self)
devices = nm_client_get_devices (self->client);
/* Cold-plug existing devices */
- for (i = 0; i < devices->len; i++)
- add_wifi_device (self, g_ptr_array_index (devices, i));
+ if (devices)
+ {
+ for (i = 0; i < devices->len; i++)
+ add_wifi_device (self, g_ptr_array_index (devices, i));
+ }
check_main_stack_page (self);
}