Commit 76aa8ce4 authored by Dan Williams's avatar Dan Williams

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.
parent 4809898e
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment