How shall gtkmm wrap a returned cairo_surface_t pointer when it's a nullptr?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How shall gtkmm wrap a returned cairo_surface_t pointer when it's a nullptr?

Kjell Ahlstedt-2

In gtk+4, GdkPixbuf has been replaced by cairo_surface_t in many functions.

A cairo_surface_t pointer is wrapped in a Cairo::RefPtr<Cairo::Surface>. There are two alternatives for wrapping a returned cairo_surface_t pointer when it's a nullptr.

1. Cairo::make_refptr_for_instance<Cairo::Surface>(nullptr)
2.
Cairo::make_refptr_for_instance<Cairo::Surface>(new Cairo::Surface(nullptr, has_reference))

Alternative 2 is used in gtkmm methods that have previously returned a Cairo::RefPtr<Cairo::Surface>. Alternative 1 is more like how subclasses of GObject are wrapped. The wrap() functions in glibmm and gtkmm return a nullptr if they are given a nullptr to wrap. I would recommend alternative 1 also for cairomm objects. Other opinions? I suppose that there has been a reason for choosing alternative 2.


_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: How shall gtkmm wrap a returned cairo_surface_t pointer when it's a nullptr?

Murray Cumming-5
On Tue, 2017-10-24 at 10:48 +0200, Kjell Ahlstedt wrote:
> 1. Cairo::make_refptr_for_instance<Cairo::Surface>(nullptr)

This seems obviously better, or maybe something even simpler.

--
Murray Cumming
[hidden email]
www.murrayc.com

_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list