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 656014 - Missing GIR annotation/wrapper for pango_layout_get_line_readonly()
Missing GIR annotation/wrapper for pango_layout_get_line_readonly()
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
1.29.x
Other Linux
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2011-08-05 07:59 UTC by Michael Vogt
Modified: 2011-08-09 08:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch that works for me (with the caveat outlned about accessing line.layout) (1.11 KB, patch)
2011-08-08 09:37 UTC, Michael Vogt
none Details | Review

Description Michael Vogt 2011-08-05 07:59:42 UTC
When running the attached python test snippet I get the following warning:

(pango.py:4596): Pango-CRITICAL **: pango_layout_line_unref: assertion `private->ref_count > 0' failed

I ran into this problem in custom cell renderer and there I get a segfault, not only the warning.

It seems like pango_layout_get_line_readonly() (and _get_line()) need some more wrapping. 

I looked into the code and one fix might be to simply set (transfer none) in the annotation for _get_line_readonly(). That fixes the issue for me, but it of course has the problem that if layout gets destroyed accessing line.layout causes a segfault. So line.layout would need a manual ref() to ensure its not destroyed while line is around.

Thanks,
 Michael
Comment 1 Michael Vogt 2011-08-05 08:01:18 UTC
Here is the example snippet:

#!/usr/bin/python

from gi.repository import Gtk, GObject

def create_layout_and_let_it_go_out_of_scope_again():
    widget = Gtk.Button()
    layout = widget.create_pango_layout("some\nlayout\n")
    #print layout
    line = layout.get_line_readonly(0)
    #print line
    

if __name__ == "__main__":
    create_layout_and_let_it_go_out_of_scope_again()


    GObject.timeout_add_seconds(1, Gtk.main_quit)
    Gtk.main()
Comment 2 Michael Vogt 2011-08-08 09:37:09 UTC
Created attachment 193397 [details] [review]
patch that works for me (with the caveat outlned about accessing line.layout)
Comment 3 Martin Pitt 2011-08-09 08:44:23 UTC
The patch might not be sufficient for your needs, but it is correct in any case, as it does not make a copy of the returned line (which is the very purpose of the _readonly() functions, after all). Also, it documents that you have to ref/unref the retured value yourself if you keep it around for a longer time, so I don't actually think this is a bug?

I pushed your patch, thanks!