From d20bed069c718e161f0a2457c9fb8204fc5c9fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Wed, 9 Sep 2015 10:59:47 +0200 Subject: libnm: fix initializing of new connections connection_added() can be called before init_get_settings_cb(), and we can't complete the connection until it is visible, else it would be uninitialized. Test case: * have 'em1' interface $ nmcli con add type ethernet con-name myeth ifname em1 autoconnect no (process:9039): libnm-CRITICAL **: nm_connection_get_id: assertion 's_con != NULL' failed Connection '(null)' ((null)) successfully added. $ nmcli con add type ethernet con-name myeth ifname em1X autoconnect no Connection 'myeth' (71159504-c2af-4773-8ca9-a3626aa0da33) successfully added. https://bugzilla.gnome.org/show_bug.cgi?id=754767 https://bugzilla.gnome.org/show_bug.cgi?id=754794 [lkundrak@v3.sk: This is not quite the correct fix, we shouldn't emit NMObject:connection-added for an unfinished object. Nevertheless, let's go with it until we have a better one. Will revert this afterwards. See linked bugs.] --- libnm/nm-remote-connection.c | 1 + libnm/nm-remote-settings.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c index e2073784ca..e5c5b99491 100644 --- a/libnm/nm-remote-connection.c +++ b/libnm/nm-remote-connection.c @@ -706,6 +706,7 @@ init_get_settings_cb (GObject *proxy, priv->visible = TRUE; replace_settings (init_data->connection, settings); g_variant_unref (settings); + g_object_notify (init_data->connection, NM_REMOTE_CONNECTION_VISIBLE); init_async_complete (init_data, NULL); } diff --git a/libnm/nm-remote-settings.c b/libnm/nm-remote-settings.c index 4d240e3b38..b25fa65983 100644 --- a/libnm/nm-remote-settings.c +++ b/libnm/nm-remote-settings.c @@ -237,8 +237,10 @@ connection_added (NMRemoteSettings *self, if (nm_remote_connection_get_visible (remote)) g_ptr_array_add (priv->visible_connections, remote); - else + else { g_signal_stop_emission (self, signals[CONNECTION_ADDED], 0); + return; + } path = nm_connection_get_path (NM_CONNECTION (remote)); addinfo = add_connection_info_find (self, path); -- cgit v1.2.1