GNOME Bugzilla – Bug 679473
Don't generate invalid property names
Last modified: 2012-07-06 13:32:58 UTC
I have a property with the name "type-" on the UDisksPartitionTable type (it's a GInterface). For some reason g-ir-scanner complains about it even though it is a perfectly valid name [1], see [2] for warnings. This is the relevant registration code: /** * UDisksPartitionTable:type-: * * Represents the D-Bus property <link linkend="gdbus-property-org-freedesktop-UDisks2-PartitionTable.Type">"Type"</link>. * * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side. */ g_object_interface_install_property (iface, g_param_spec_string ("type-", "Type", "Type", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); [1] : it was chosen by gdbus-codegen(1) as the GObject property name for a D-Bus property with the name "Type".... [2] : udisks-generated.c:14056: Warning: UDisks: ignoring unrecognized GTK-Doc comment block, identifier not found: * UDisksPartitionTable:type-: ^ udisks-generated.c:15628: Warning: UDisks: ignoring unrecognized GTK-Doc comment block, identifier not found: * UDisksPartition:type-: ^ g-ir-scanner: compile: gcc -Wall -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I.. -I.. -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -c -o /ostbuild/source/udisks/_build/udisks/tmp-introspect8jJo0X/UDisks-2.0.o /ostbuild/source/udisks/_build/udisks/tmp-introspect8jJo0X/UDisks-2.0.c
Looking more closely at this, the docs for g_param_spec_internal() state A property name consists of segments consisting of ASCII letters and digits, separated by either the '-' or '_' character. The first character of a property name must be a letter. Names which violate these rules lead to undefined behaviour. which suggest that the property name "type-" actually is invalid... so we have two options now - retroactively allow property names ending in '-' - fix gdbus-codegen(1) to not use invalid property names The latter would perhaps break some generated code (libudisks2 in particular) but I don't think that matters _that_ much since the name was invalid in the first place. So I think we should probably just fix gdbus-codegen(1) instead... thoughts?
OK, fixed in gdbus-codegen along with a test case, see http://git.gnome.org/browse/glib/commit/?id=d72116d8b7c802895be6b02093342fd9e770813d for details.
Created attachment 218182 [details] [review] Change in udisks generated code This is the change in the generated code for a fairly complex set of D-Bus interfaces - as you can see only the GObject property has changed (the float comparison change is from bug 678333).