From 88f0d646d5089dfc8df9b03750ade72e921803eb Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 8 Sep 2015 19:16:50 +0200 Subject: [PATCH] libnm: don't add objects to cache until they're async-inited Otherwise the uninitializeded objects could be prematurely signalled if their paths are seen twice in quick succession. This happens when you have ethernet hardware and add an ethernet connection -- it's immediatelly added to AvialableConnections and the property reload signals the object addition before the NMRemoteSettings's GetSettings() finishes: # nmcli c add type ethernet autoconnect no ifname '*' (process:4610): libnm-CRITICAL **: nm_connection_get_id: assertion 's_con != NULL' failed Connection '(null)' ((null)) successfully added. # https://bugzilla.gnome.org/show_bug.cgi?id=754794 --- libnm/nm-object.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libnm/nm-object.c b/libnm/nm-object.c index 2aaa4d9d96..36a5d173a4 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -468,6 +468,11 @@ create_async_inited (GObject *object, GAsyncResult *result, gpointer user_data) } create_async_complete (object, async_data); + + if (_nm_object_cache_get (async_data->path)) + g_clear_object (&object); + else + _nm_object_cache_add (NM_OBJECT (object)); } static void @@ -496,7 +501,6 @@ create_async_got_type (NMObjectTypeAsyncData *async_data, GType type) NM_OBJECT_PATH, async_data->path, NM_OBJECT_DBUS_CONNECTION, async_data->connection, NULL); - _nm_object_cache_add (NM_OBJECT (object)); g_async_initable_init_async (G_ASYNC_INITABLE (object), G_PRIORITY_DEFAULT, NULL, create_async_inited, async_data); }