Re: Replace Gtk::manage() with std::unique_ptr<>?



On Mon, 2016-02-08 at 22:26 +0100, Jonas Platte wrote:
The logic for the ownership management is in the C libraries? There
is
no equivalent to Gtk::manage in gtk+ though, right?

It's the default behaviour with the C GTK+ API. We make it optional, so
we can use normal C++ object lifetimes, such as for member variables,
without dynamic allocation.

Well, if the implementation uses Glib::RefPtr<>, why not just create
overloads of all the functions that take references, so they also
allow
Glib::RefPtr<>? Then you could create a replacement for Gtk::manage
that
is the equivalent of std::make_shared() for Glib::RefPtr<>. And if
you
were to move to std::shared_ptr<> in a later version, the transition
would be a simple 's/make_ref_ptr/make_shared/'.

RefPtr<> currently cannot be used with widgets, because widgets are not
simply reference-counted. Using either RefPtr<> or shared_ptr<> for
widgets is a much bigger change, for a later time.

-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com





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