GNOME Bugzilla – Bug 797137
avoid using deprecated gdk_pixbuf_new_from_inline()
Last modified: 2019-09-13 08:54:14 UTC
libgtk3-perl currently uses gdk_pixbuf_new_from_inline() to implement Gtk3::Gdk::Pixbuf::new_from_data, because using gdk_pixbuf_new_from_data() would require being able to hand over ownership of a buffer to gdk-pixbuf, whereas gdk_pixbuf_new_from_inline() copies the input. However, gdk_pixbuf_new_from_inline() is deprecated. A gdk-pixbuf maintainer recommends[1] using GBytes and new_from_bytes(), which is also what pygobject does in its own overrides: > # /usr/lib/python3/dist-packages/gi/overrides/GdkPixbuf.py > @override > class Pixbuf(GdkPixbuf.Pixbuf): > > @classmethod > def new_from_data( > cls, data, colorspace, has_alpha, bits_per_sample, > width, height, rowstride, > destroy_fn=None, *destroy_fn_data): > > if destroy_fn is not None: > w = PyGIDeprecationWarning("destroy_fn argument deprecated") > warnings.warn(w) > if destroy_fn_data: > w = PyGIDeprecationWarning("destroy_fn_data argument deprecated") > warnings.warn(w) > > data = GLib.Bytes.new(data) > return cls.new_from_bytes( > data, colorspace, has_alpha, bits_per_sample, > width, height, rowstride) In Perl I think that would be spelled something like: sub Gtk3::Gdk::Pixbuf::new_from_data { my ($class, $data, $colorspace, $has_alpha, $bits_per_sample, $width, $height, $rowstride) = @_; return Gtk3::Gdk::Pixbuf->new_from_bytes(GLib::Bytes->new($data), $colorspace, $has_alpha, $bits_per_sample, $width, $height, $rowstride); } (but please note that I have not tested that at all.) It looks as though this might even add support for bits per sample != 8 and non-RGB colour spaces as a side effect, if the underlying library ever supports them (but it currently doesn't, and that probably won't change). [1] on https://gitlab.gnome.org/GNOME/gdk-pixbuf/merge_requests/17
https://gitlab.gnome.org/GNOME/perl-gtk3/merge_requests/2 implements what Simon suggested.