From 76aa8ce40eafbf523b9390bfff0ffb1227984368 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 22 May 2014 13:59:06 -0500 Subject: [PATCH] core: simplify DHCP cleanup dhcp6_cleanup() frees priv->dhcp6_ip6_config so dispose() doesn't need to do that. Also use g_clear_object() when appropriate. Lastly, notify that the DHCP4/6 config objects have changed *after* clearing them, so that the PropertiesChanged signal is emitted with a blank path to indicate the object is gone. Previously the PC signal would have been emitted with the valid path of the DHCP4/6 config object, but the object would already be dead. --- src/devices/nm-device.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index e3ef0c8691..99dd138929 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2502,9 +2502,8 @@ dhcp4_cleanup (NMDevice *self, gboolean stop, gboolean release) NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); if (priv->dhcp4_config) { + g_clear_object (&priv->dhcp4_config); g_object_notify (G_OBJECT (self), NM_DEVICE_DHCP4_CONFIG); - g_object_unref (priv->dhcp4_config); - priv->dhcp4_config = NULL; } if (priv->dhcp4_client) { @@ -2524,8 +2523,7 @@ dhcp4_cleanup (NMDevice *self, gboolean stop, gboolean release) if (stop) nm_dhcp_client_stop (priv->dhcp4_client, release); - g_object_unref (priv->dhcp4_client); - priv->dhcp4_client = NULL; + g_clear_object (&priv->dhcp4_client); } } @@ -2944,16 +2942,11 @@ dhcp6_cleanup (NMDevice *self, gboolean stop, gboolean release) NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); priv->dhcp6_mode = NM_RDISC_DHCP_LEVEL_NONE; - - if (priv->dhcp6_ip6_config) { - g_object_unref (priv->dhcp6_ip6_config); - priv->dhcp6_ip6_config = NULL; - } + g_clear_object (&priv->dhcp6_ip6_config); if (priv->dhcp6_config) { + g_clear_object (&priv->dhcp6_config); g_object_notify (G_OBJECT (self), NM_DEVICE_DHCP6_CONFIG); - g_object_unref (priv->dhcp6_config); - priv->dhcp6_config = NULL; } if (priv->dhcp6_client) { @@ -2972,8 +2965,7 @@ dhcp6_cleanup (NMDevice *self, gboolean stop, gboolean release) if (stop) nm_dhcp_client_stop (priv->dhcp6_client, release); - g_object_unref (priv->dhcp6_client); - priv->dhcp6_client = NULL; + g_clear_object (&priv->dhcp6_client); } } @@ -7169,11 +7161,10 @@ dispose (GObject *object) g_clear_object (&priv->vpn4_config); g_clear_object (&priv->ip4_config); - g_clear_object (&priv->ip6_config); g_clear_object (&priv->ac_ip6_config); - g_clear_object (&priv->dhcp6_ip6_config); - g_clear_object (&priv->vpn6_config); g_clear_object (&priv->ext_ip6_config); + g_clear_object (&priv->vpn6_config); + g_clear_object (&priv->ip6_config); g_clear_pointer (&priv->ip6_saved_properties, g_hash_table_unref);