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



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.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]