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 651132 - Strings in a boxed type get treated as weak references
Strings in a boxed type get treated as weak references
Status: RESOLVED DUPLICATE of bug 561619
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: 2011-05-26 10:33 UTC by Raul Gutierrez Segales
Modified: 2015-02-07 16:45 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Raul Gutierrez Segales 2011-05-26 10:33:15 UTC
Given the following C code:

typedef struct {
	gchar *family;
	gchar *given;
	gchar *additional;
	gchar *prefixes;
	gchar *suffixes;
} EContactName;

(skipping the copy/free methods APIs)

and the following GIR code:

    <record name="ContactName"
            c:type="EContactName"
            glib:type-name="EContactName"
            glib:get-type="e_contact_name_get_type"
            c:symbol-prefix="contact_name">
      <field name="family" writable="1">
        <type name="utf8" c:type="gchar*"/>
      </field>
      <field name="given" writable="1">
        <type name="utf8" c:type="gchar*"/>
      </field>
      <field name="additional" writable="1">
        <type name="utf8" c:type="gchar*"/>
      </field>
      <field name="prefixes" writable="1">
        <type name="utf8" c:type="gchar*"/>
      </field>
      <field name="suffixes" writable="1">
        <type name="utf8" c:type="gchar*"/>
      </field>
      <constructor name="new" c:identifier="e_contact_name_new">
        <doc xml:whitespace="preserve">Creates a new #EContactName struct.</doc>
        <return-value transfer-ownership="full">
          <doc xml:whitespace="preserve">A new #EContactName struct.</doc>
          <type name="ContactName" c:type="EContactName*"/>
        </return-value>
      </constructor>
      <method name="copy" c:identifier="e_contact_name_copy">
        <doc xml:whitespace="preserve">Creates a copy of @n.</doc>
        <return-value transfer-ownership="full">
          <doc xml:whitespace="preserve">A new #EContactName identical to @n.</doc>
          <type name="ContactName" c:type="EContactName*"/>
        </return-value>
      </method>
      <method name="free" c:identifier="e_contact_name_free">
        <doc xml:whitespace="preserve">Frees @name and its contents.</doc>
        <return-value transfer-ownership="none">
          <type name="none" c:type="void"/>
        </return-value>
      </method>
      <method name="to_string" c:identifier="e_contact_name_to_string">
        <doc xml:whitespace="preserve">Generates a string representation of @name.</doc>
        <return-value transfer-ownership="full">
          <doc xml:whitespace="preserve">The string representation of @name.</doc>
          <type name="utf8" c:type="gchar*"/>
        </return-value>
      </method>
    </record>


Vapigen generates the following (incorrect?) definitions:

	[CCode (copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "e_contact_address_get_type ()", cheader_filename = "libebook/e-book.h")]
	public class ContactAddress {
		public weak string address_format;
		public weak string code;
		public weak string country;
		public weak string ext;
		public weak string locality;
		public weak string po;
		public weak string region;
		public weak string street;
		public void free ();
	}
Comment 1 Luca Bruno 2011-05-26 15:07:19 UTC
Reassigning to gobject-introspection. The gir format has not enough information whether assigning to a field should transfer ownership or not.
Comment 2 Johan (not receiving bugmail) Dahlin 2011-08-26 10:09:23 UTC

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