After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 619799 - gchar** inside a struct is not introspected correctly
gchar** inside a struct is not introspected correctly
Status: RESOLVED DUPLICATE of bug 620170
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2010-05-27 10:01 UTC by Xavier Claessens
Modified: 2015-02-07 17:03 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Xavier Claessens 2010-05-27 10:01:46 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**.
Comment 1 Xavier Claessens 2010-05-27 13:38:03 UTC
(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
Comment 2 Xavier Claessens 2010-05-27 14:14:52 UTC
I tried to annotated the gchar** struct field with that: "(array zero-terminated=1) (element-type utf8)", but it didn't change anything.
Comment 3 Xavier Claessens 2010-05-27 14:43:01 UTC
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.
Comment 4 Tomeu Vizoso 2010-05-27 14:46:39 UTC
(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"/>
Comment 5 Xavier Claessens 2010-06-01 16:28:04 UTC

*** This bug has been marked as a duplicate of bug 620170 ***
Comment 6 André Klapper 2015-02-07 17:03:10 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]