GNOME Bugzilla – Bug 619799
gchar** inside a struct is not introspected correctly
Last modified: 2015-02-07 17:03:10 UTC
Telepathy-glib has this in its API: typedef struct _TpAvatarRequirements TpAvatarRequirements; struct _TpAvatarRequirements { gchar **supported_mime_types; ... }; That generate in the .gir file: <field name="supported_mime_types" writable="1"> <type name="utf8" c:type="gchar**"/> </field> If I try to print that value in a python code, it shows garbage, because it thinks it is a string, but it is a strv. I tested with adding "(array zero-terminated=1)" annotation in the struct doc, but that does not change anything. In function calls, if an arg is of type gchar** then it is correctly introspected like this (even if no annotation is given): <parameter name="supported_mime_types" transfer-ownership="none"> <type name="GObject.Strv" c:type="GStrv"/> </parameter> Btw, we were using GStrv typedef in various APIs because that was supposed to be binding-friendly, but it is not parsed at all, so we had to revert to use gchar**.
(In reply to comment #0) > In function calls, if an arg is of type gchar** then it is correctly > introspected like this (even if no annotation is given): > > <parameter name="supported_mime_types" transfer-ownership="none"> > <type name="GObject.Strv" c:type="GStrv"/> > </parameter> Sorry that's because it is a GStrv in function args. But if I use GStrv in structs then I get an error when running g-ir-compiler: ** WARNING **: field TelepathyGLib.ContactInfoFieldSpec.parameters has void type
I tried to annotated the gchar** struct field with that: "(array zero-terminated=1) (element-type utf8)", but it didn't change anything.
I tested functions that have a 'GStrv' in parameters. As said above those are introspected (correctly?) like that: <parameter name="field_value" transfer-ownership="none"> <type name="GObject.Strv" c:type="GStrv"/> </parameter> But calling that function with '[]' or '["test1", "test2"]' make a segfault in the function implementation, when doing a g_strdupv() on the arg.
(In reply to comment #3) > I tested functions that have a 'GStrv' in parameters. As said above those are > introspected (correctly?) like that: > > <parameter name="field_value" transfer-ownership="none"> > <type name="GObject.Strv" c:type="GStrv"/> > </parameter> > > But calling that function with '[]' or '["test1", "test2"]' make a segfault in > the function implementation, when doing a g_strdupv() on the arg. The parameter has been introspected correctly but GStrv itself isn't, in GObject-2.0.gir: <alias name="Strv" target="none" c:type="GStrv"/>
*** This bug has been marked as a duplicate of bug 620170 ***
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]