mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
gdbus-codegen: Never emit empty PropertiesChanged signals
It's not that it's actually a bug to do so per se, strictly speaking, it's just pointless and wasteful. Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
parent
6bccc46d15
commit
a3fa748e54
@ -1705,9 +1705,10 @@ class CodeGenerator:
|
||||
self.c.write(' GList *l;\n'
|
||||
' GVariantBuilder builder;\n'
|
||||
' GVariantBuilder invalidated_builder;\n'
|
||||
' guint num_changes;\n'
|
||||
' g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));\n'
|
||||
' g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));\n'
|
||||
' for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)\n'
|
||||
' for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next)\n'
|
||||
' {\n'
|
||||
' ChangedProperty *cp = l->data;\n'
|
||||
' GVariant *variant;\n'
|
||||
@ -1719,16 +1720,25 @@ class CodeGenerator:
|
||||
' variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature));\n'
|
||||
' g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);\n'
|
||||
' g_variant_unref (variant);\n'
|
||||
' num_changes++;\n'
|
||||
' }\n'
|
||||
' }\n'
|
||||
' g_dbus_connection_emit_signal (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)),\n'
|
||||
' NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),\n'
|
||||
' "org.freedesktop.DBus.Properties",\n'
|
||||
' "PropertiesChanged",\n'
|
||||
' g_variant_new ("(sa{sv}as)",\n'
|
||||
' "%s",\n'
|
||||
' &builder, &invalidated_builder),\n'
|
||||
' NULL);\n'
|
||||
' if (num_changes > 0)\n'
|
||||
' {\n'
|
||||
' g_dbus_connection_emit_signal (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)),\n'
|
||||
' NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),\n'
|
||||
' "org.freedesktop.DBus.Properties",\n'
|
||||
' "PropertiesChanged",\n'
|
||||
' g_variant_new ("(sa{sv}as)",\n'
|
||||
' "%s",\n'
|
||||
' &builder, &invalidated_builder),\n'
|
||||
' NULL);\n'
|
||||
' }\n'
|
||||
' else\n'
|
||||
' {\n'
|
||||
' g_variant_builder_clear (&builder);\n'
|
||||
' g_variant_builder_clear (&invalidated_builder);\n'
|
||||
' }\n'
|
||||
%(i.name))
|
||||
self.c.write(' g_list_foreach (skeleton->priv->changed_properties, (GFunc) _changed_property_free, NULL);\n')
|
||||
self.c.write(' g_list_free (skeleton->priv->changed_properties);\n')
|
||||
|
Loading…
Reference in New Issue
Block a user