diff --git a/src/libnm-core-impl/nm-setting.c b/src/libnm-core-impl/nm-setting.c index 8c129df7f..27f835961 100644 --- a/src/libnm-core-impl/nm-setting.c +++ b/src/libnm-core-impl/nm-setting.c @@ -993,6 +993,10 @@ out_notify: * * Currently we never set that, also because we still support glib 2.40. */ nm_assert(!NM_FLAGS_HAS(pspec->flags, 1 << 30 /* G_PARAM_EXPLICIT_NOTIFY */)); + + /* We only notify "direct_also_notify". The other property is automatically notified. */ + nm_gobject_notify_together_by_pspec(object, property_info->direct_also_notify); + return; out_fail: @@ -1388,7 +1392,9 @@ _nm_setting_property_from_dbus_fcn_direct_mac_address(_NM_SETT_INFO_PROP_FROM_DB if (nm_strdup_reset_take(_nm_setting_get_private_field(setting, sett_info, property_info), length > 0 ? nm_utils_hwaddr_ntoa(array, length) : NULL)) { - g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec); + nm_gobject_notify_together_by_pspec(setting, + property_info->param_spec, + property_info->direct_also_notify); } else *out_is_modified = FALSE; @@ -1692,7 +1698,9 @@ out_unchanged: out_notify: *out_is_modified = TRUE; - g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec); + nm_gobject_notify_together_by_pspec(setting, + property_info->param_spec, + property_info->direct_also_notify); return TRUE; out_error_wrong_dbus_type: diff --git a/src/libnm-core-impl/tests/test-setting.c b/src/libnm-core-impl/tests/test-setting.c index e799069d7..f42f6fa74 100644 --- a/src/libnm-core-impl/tests/test-setting.c +++ b/src/libnm-core-impl/tests/test-setting.c @@ -4749,6 +4749,24 @@ test_setting_metadata(void) if (!can_have_direct_set_fcn) g_assert(!sip->direct_set_fcn.set_string); + if (sip->property_type->direct_type == NM_VALUE_TYPE_NONE) + g_assert(!sip->direct_also_notify); + else { + if (sip->direct_also_notify) { + guint prop_idx2; + guint cnt = 0; + + for (prop_idx2 = 0; prop_idx2 < sis->property_infos_len; prop_idx2++) { + const NMSettInfoProperty *sip2 = &sis->property_infos[prop_idx2]; + + if (sip2->param_spec == sip->direct_also_notify) + cnt++; + } + g_assert_cmpint(cnt, ==, 1u); + g_assert(sip->param_spec != sip->direct_also_notify); + } + } + n_special_options = (sip->direct_set_string_mac_address_len != 0) + (!!sip->direct_set_string_strip) + (!!sip->direct_set_string_ascii_strdown) diff --git a/src/libnm-core-intern/nm-core-internal.h b/src/libnm-core-intern/nm-core-internal.h index 42ddeb5e1..efc2613a2 100644 --- a/src/libnm-core-intern/nm-core-internal.h +++ b/src/libnm-core-intern/nm-core-internal.h @@ -784,6 +784,10 @@ struct _NMSettInfoProperty { const char *src); } direct_set_fcn; + /* For direct properties, this is the param_spec that also should be + * notified on changes. */ + GParamSpec *direct_also_notify; + /* This only has meaning for direct properties (property_type->direct_type != NM_VALUE_TYPE_UNSPEC). * In that case, this is the offset where _nm_setting_get_private() can find * the direct location. */