diff options
author | Andrew Zaborowski <andrew.zaborowski@intel.com> | 2018-01-22 19:38:29 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-02-09 21:30:46 +0100 |
commit | d32987fdd19b14b16409f6f8578e66e26bb3793f (patch) | |
tree | 45a63067124454f1333080d7e2733a2bfdde69ac /src/devices/wifi/nm-iwd-manager.c | |
parent | eea06b8a8cf144fd6436879d78d6c50e0e4b8849 (diff) |
iwd: keep reference to NMManager, disconnect signals
Disconnect from NMManager signals in our cleanup, make sure the
NMManager singleton is not destroyed before we are by keeping a
reference until we've disconnected from its signals.
Diffstat (limited to 'src/devices/wifi/nm-iwd-manager.c')
-rw-r--r-- | src/devices/wifi/nm-iwd-manager.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/devices/wifi/nm-iwd-manager.c b/src/devices/wifi/nm-iwd-manager.c index 4eda5ebac..26553fd6b 100644 --- a/src/devices/wifi/nm-iwd-manager.c +++ b/src/devices/wifi/nm-iwd-manager.c @@ -39,6 +39,7 @@ typedef struct { } KnownNetworkData; typedef struct { + NMManager *nm_manager; GCancellable *cancellable; gboolean running; GDBusObjectManager *object_manager; @@ -97,7 +98,6 @@ psk_agent_dbus_method_cb (GDBusConnection *connection, gs_unref_object GDBusInterface *network = NULL, *device_obj = NULL; gs_unref_variant GVariant *value = NULL; gint ifindex; - NMManager *manager; NMDevice *device; const gchar *psk; @@ -139,9 +139,7 @@ psk_agent_dbus_method_cb (GDBusConnection *connection, goto return_error; } - manager = nm_manager_get (); - - device = nm_manager_get_device_by_ifindex (manager, ifindex); + device = nm_manager_get_device_by_ifindex (priv->nm_manager, ifindex); if (!NM_IS_DEVICE_IWD (device)) { _LOGE ("IWD device named %s is not a Wifi device in IWD Agent request", ifname); @@ -271,7 +269,6 @@ set_device_dbus_object (NMIwdManager *self, GDBusInterface *interface, const char *ifname; gint ifindex; NMDevice *device; - NMManager *manager; if (!priv->running) return; @@ -301,9 +298,7 @@ set_device_dbus_object (NMIwdManager *self, GDBusInterface *interface, return; } - manager = nm_manager_get (); - - device = nm_manager_get_device_by_ifindex (manager, ifindex); + device = nm_manager_get_device_by_ifindex (priv->nm_manager, ifindex); if (!NM_IS_DEVICE_IWD (device)) { _LOGE ("IWD device named %s is not a Wifi device", ifname); return; @@ -481,12 +476,11 @@ name_owner_changed (GObject *object, GParamSpec *pspec, gpointer user_data) update_known_networks (self); } else { - NMManager *manager = nm_manager_get (); const GSList *devices, *iter; priv->running = false; - devices = nm_manager_get_devices (manager); + devices = nm_manager_get_devices (priv->nm_manager); for (iter = devices; iter; iter = iter->next) { NMDevice *device = NM_DEVICE (iter->data); @@ -554,7 +548,6 @@ got_object_manager (GObject *object, GAsyncResult *result, gpointer user_data) GError *error = NULL; GDBusObjectManager *object_manager; GDBusConnection *connection; - NMManager *manager = nm_manager_get (); g_clear_object (&priv->cancellable); @@ -588,9 +581,6 @@ got_object_manager (GObject *object, GAsyncResult *result, gpointer user_data) } name_owner_changed (G_OBJECT (object_manager), NULL, self); - - g_signal_connect (manager, "device-added", - G_CALLBACK (device_added), self); } static void @@ -649,6 +639,10 @@ nm_iwd_manager_init (NMIwdManager *self) { NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE (self); + priv->nm_manager = g_object_ref (nm_manager_get ()); + g_signal_connect (priv->nm_manager, "device-added", + G_CALLBACK (device_added), self); + priv->cancellable = g_cancellable_new (); prepare_object_manager (self); } @@ -684,6 +678,9 @@ dispose (GObject *object) g_slist_free_full (priv->known_networks, (GDestroyNotify) known_network_free); priv->known_networks = NULL; + g_signal_handlers_disconnect_by_data (priv->nm_manager, self); + g_clear_object (&priv->nm_manager); + G_OBJECT_CLASS (nm_iwd_manager_parent_class)->dispose (object); } |