On Thu, 2017-03-16 at 14:34 +0100, Kjell Ahlstedt wrote:
> The const usage is wrong in both get_pixels() methods. Should be
> _WRAP_METHOD(guint8* get_pixels(), gdk_pixbuf_get_pixels)
> _WRAP_METHOD(guint8* get_pixels(guint& length),
> and perhaps
> _WRAP_METHOD(const guint8* get_pixels() const,
> gdk_pixbuf_get_pixels, constversion)
> _WRAP_METHOD(const guint8* get_pixels(guint& length) const,
> gdk_pixbuf_get_pixels_with_length, constversion)
> The documentation of gdk_pixbuf_get_pixels[_with_length]() says
> "This function will cause an implicit copy of the pixbuf data if the
> pixbuf was created from read-only data."
> I take this to mean that it's alright for the caller to change the
> pixel data. (The implicit copy is owned by the GdkPixbuf object. The
> caller shall not delete it.) There is also the
> gdk_pixbuf_read_pixels() function (not yet wrapped in Gdk::Pixbuf)
> which returns a const guint8*. It's perhaps a better choice when you
> don't want to change the pixels, because it does not make a copy of
> read-only data.
On Fri, 2017-03-17 at 07:55 +0000, Daniel Boles wrote:
> The copy is done as follows, to support copy-on-write:
> * This function will cause an implicit copy of the pixbuf data if
> * pixbuf was created from read-only data.
> https://git.gnome.org/browse/gdk-pixbuf/tree/gdk-pixbuf/gdk-pixbuf.c# > n674
> I thought as long as the apparent functioning of the object is still
> the same to external users, then it is allowed to make internal
> changes even on a const instance? Using mutable members.
> If so, then maybe it would still be OK to wrap that as a const
We are wrapping that as a const method. But we don't need to make
anything mutable. We just const_cast the GdkPixbuf*. C doesn't do full
C++-like const, so this is often necessary.
If I have misunderstood, maybe you could suggest a particular patch.