libnm-core: don't emit signal when clearing lists already empty

If the property is a list and it is already empty, we should not emit
a signal when it gets cleared.
This commit is contained in:
Beniamino Galvani
2018-05-28 15:31:11 +02:00
parent 347e0d8b5a
commit a2846bd735
4 changed files with 34 additions and 16 deletions

View File

@@ -1589,8 +1589,11 @@ nm_setting_ip_config_clear_dns (NMSettingIPConfig *setting)
g_return_if_fail (NM_IS_SETTING_IP_CONFIG (setting));
priv = NM_SETTING_IP_CONFIG_GET_PRIVATE (setting);
g_ptr_array_set_size (priv->dns, 0);
g_object_notify (G_OBJECT (setting), NM_SETTING_IP_CONFIG_DNS);
if (priv->dns->len != 0) {
g_ptr_array_set_size (priv->dns, 0);
g_object_notify (G_OBJECT (setting), NM_SETTING_IP_CONFIG_DNS);
}
}
/**
@@ -1727,8 +1730,11 @@ nm_setting_ip_config_clear_dns_searches (NMSettingIPConfig *setting)
g_return_if_fail (NM_IS_SETTING_IP_CONFIG (setting));
priv = NM_SETTING_IP_CONFIG_GET_PRIVATE (setting);
g_ptr_array_set_size (priv->dns_search, 0);
g_object_notify (G_OBJECT (setting), NM_SETTING_IP_CONFIG_DNS_SEARCH);
if (priv->dns_search->len != 0) {
g_ptr_array_set_size (priv->dns_search, 0);
g_object_notify (G_OBJECT (setting), NM_SETTING_IP_CONFIG_DNS_SEARCH);
}
}
/**
@@ -2107,8 +2113,10 @@ nm_setting_ip_config_clear_addresses (NMSettingIPConfig *setting)
g_return_if_fail (NM_IS_SETTING_IP_CONFIG (setting));
g_ptr_array_set_size (priv->addresses, 0);
g_object_notify (G_OBJECT (setting), NM_SETTING_IP_CONFIG_ADDRESSES);
if (priv->addresses->len != 0) {
g_ptr_array_set_size (priv->addresses, 0);
g_object_notify (G_OBJECT (setting), NM_SETTING_IP_CONFIG_ADDRESSES);
}
}
/**
@@ -2264,8 +2272,10 @@ nm_setting_ip_config_clear_routes (NMSettingIPConfig *setting)
g_return_if_fail (NM_IS_SETTING_IP_CONFIG (setting));
g_ptr_array_set_size (priv->routes, 0);
g_object_notify (G_OBJECT (setting), NM_SETTING_IP_CONFIG_ROUTES);
if (priv->routes->len != 0) {
g_ptr_array_set_size (priv->routes, 0);
g_object_notify (G_OBJECT (setting), NM_SETTING_IP_CONFIG_ROUTES);
}
}
/**

View File

@@ -982,8 +982,10 @@ nm_setting_tc_config_clear_qdiscs (NMSettingTCConfig *self)
{
g_return_if_fail (NM_IS_SETTING_TC_CONFIG (self));
g_ptr_array_set_size (self->qdiscs, 0);
g_object_notify (G_OBJECT (self), NM_SETTING_TC_CONFIG_QDISCS);
if (self->qdiscs->len != 0) {
g_ptr_array_set_size (self->qdiscs, 0);
g_object_notify (G_OBJECT (self), NM_SETTING_TC_CONFIG_QDISCS);
}
}
/*****************************************************************************/
@@ -1116,8 +1118,10 @@ nm_setting_tc_config_clear_tfilters (NMSettingTCConfig *self)
{
g_return_if_fail (NM_IS_SETTING_TC_CONFIG (self));
g_ptr_array_set_size (self->tfilters, 0);
g_object_notify (G_OBJECT (self), NM_SETTING_TC_CONFIG_TFILTERS);
if (self->tfilters->len != 0) {
g_ptr_array_set_size (self->tfilters, 0);
g_object_notify (G_OBJECT (self), NM_SETTING_TC_CONFIG_TFILTERS);
}
}
/*****************************************************************************/

View File

@@ -322,8 +322,10 @@ nm_setting_team_port_clear_link_watchers (NMSettingTeamPort *setting)
g_return_if_fail (NM_IS_SETTING_TEAM_PORT (setting));
g_ptr_array_set_size (priv->link_watchers, 0);
g_object_notify (G_OBJECT (setting), NM_SETTING_TEAM_PORT_LINK_WATCHERS);
if (priv->link_watchers->len != 0) {
g_ptr_array_set_size (priv->link_watchers, 0);
g_object_notify (G_OBJECT (setting), NM_SETTING_TEAM_PORT_LINK_WATCHERS);
}
}
static GVariant *

View File

@@ -1120,8 +1120,10 @@ nm_setting_team_clear_link_watchers (NMSettingTeam *setting) {
g_return_if_fail (NM_IS_SETTING_TEAM (setting));
g_ptr_array_set_size (priv->link_watchers, 0);
g_object_notify (G_OBJECT (setting), NM_SETTING_TEAM_LINK_WATCHERS);
if (priv->link_watchers->len != 0) {
g_ptr_array_set_size (priv->link_watchers, 0);
g_object_notify (G_OBJECT (setting), NM_SETTING_TEAM_LINK_WATCHERS);
}
}
static GVariant *