diff options
author | Dan Winship <danw@redhat.com> | 2014-12-03 17:17:08 -0500 |
---|---|---|
committer | Dan Winship <danw@redhat.com> | 2014-12-05 16:16:53 +0100 |
commit | 5bfb4c8c23e5b9d8020d6caff8c63830d2d8ec37 (patch) | |
tree | a7495e3333d9b4b949fde240b894a508995049dd /clients | |
parent | 820e41645f7173e544b31c5178fae5b40491c6a1 (diff) | |
download | NetworkManager-5bfb4c8c23e5b9d8020d6caff8c63830d2d8ec37.tar.gz |
tui: fix deletion of slaves with master (rh #1131574)
We wait for each deletion to complete, so the connections were getting
removed from the connections array as we edited it (unlike with the
old transfer-container GSList-based code). Fix this by copying the
slaves out into their own list first.
Diffstat (limited to 'clients')
-rw-r--r-- | clients/tui/nmtui-edit.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/clients/tui/nmtui-edit.c b/clients/tui/nmtui-edit.c index 94d15fb3b2..0c3206da60 100644 --- a/clients/tui/nmtui-edit.c +++ b/clients/tui/nmtui-edit.c @@ -515,7 +515,8 @@ remove_one_connection (NMRemoteConnection *connection) void nmt_remove_connection (NMRemoteConnection *connection) { - const GPtrArray *conns; + const GPtrArray *all_conns; + GSList *slaves, *iter; int i; NMRemoteConnection *slave; NMSettingConnection *s_con; @@ -535,16 +536,22 @@ nmt_remove_connection (NMRemoteConnection *connection) uuid = nm_connection_get_uuid (NM_CONNECTION (connection)); iface = nm_connection_get_interface_name (NM_CONNECTION (connection)); - conns = nm_client_get_connections (nm_client); - for (i = 0; i < conns->len; i++) { - slave = conns->pdata[i]; + all_conns = nm_client_get_connections (nm_client); + slaves = NULL; + for (i = 0; i < all_conns->len; i++) { + slave = all_conns->pdata[i]; s_con = nm_connection_get_setting_connection (NM_CONNECTION (slave)); master = nm_setting_connection_get_master (s_con); if (master) { if (!g_strcmp0 (master, uuid) || !g_strcmp0 (master, iface)) - remove_one_connection (slave); + slaves = g_slist_prepend (slaves, g_object_ref (slave)); } } + + for (iter = slaves; iter; iter = iter->next) + remove_one_connection (iter->data); + g_slist_free_full (slaves, g_object_unref); + g_object_unref (connection); } |