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 600993 - [PATCH] Pango.Attribute constructors transfer ownership, Pango.Scale not an enum
[PATCH] Pango.Attribute constructors transfer ownership, Pango.Scale not an enum
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings
0.7.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-11-06 18:57 UTC by Philipp Zabel
Modified: 2009-11-07 20:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
pango: fix Pango.Attribute constructors' transfer of ownershiper and Pango.Scale (8.57 KB, application/empty)
2009-11-06 18:57 UTC, Philipp Zabel
Details

Description Philipp Zabel 2009-11-06 18:57:27 UTC
Created attachment 147121 [details]
pango: fix Pango.Attribute constructors' transfer of ownershiper and Pango.Scale

As reported on the list
(http://mail.gnome.org/archives/vala-list/2009-November/msg00021.html), code
like this:
  1:  Pango.AttrList attr_list = new Pango.AttrList ();
  2:  Pango.Attribute attr_color = Pango.attr_foreground_new (red, green,
blue);
  3:  Pango.Attribute attr_scale = Pango.attr_scale_new (Pango.Scale.SMALL);
  4:  attr_list.insert ((owned) attr_color);
  5:  attr_list.insert ((owned) attr_scale);
  6:  renderer.attributes = attr_list;
currently fails to build because the Pango.Attribute constructor function
return values are marked as unowned.

The Pango.attr_*_new constructors return owned Pango.Attribute references. The
attached patch adds the missing transfer_owned="1" attribute in pango.metadata.

Also, Pango.Scale is not an enum. The attached patch turns it into a namespace
with double constants in pango-custom.vala. This is needed so for
Pango.attr_scale_new above. Otherwise Vala tries and fails to convert from enum
Pango.Scale to double.
Comment 1 Evan Nemerson 2009-11-07 20:02:24 UTC
commit 4fb1dbe8ed8ed12ab558f9808266b08b7fda6fee
Author: Philipp Zabel <philipp.zabel@gmail.com>
Date:   Fri Nov 6 19:43:24 2009 +0100

    pango: fix Pango.Attribute constructors' transfer of ownership and Pango.Scale
    
    The Pango.attr_*_new constructors return owned Pango.Attribute references.
    Pango.Scale is not an enum. Turn it into a namespace with double constants.
    The latter is needed so for Pango.attr_scale_new, because it is impossible
    to convert from enum Pango.Scale to double.
    
    Fixes bug 600993.