Re: When using Glib::RefPtr<> and when Pointer?
- From: Paul Davis <paul linuxaudiosystems com>
- To: Andreas Volz <lists brachttal net>
- Cc: gtkmm-list gnome org
- Subject: Re: When using Glib::RefPtr<> and when Pointer?
- Date: Mon, 20 Apr 2009 17:22:59 -0400
On Mon, Apr 20, 2009 at 5:13 PM, Andreas Volz <lists brachttal net> wrote:
> I'm a little confused about the Glib::RefPtr<> usage in gtkmm.
> For some returns are used smart pointers and for some normal pointers.
> Glib::RefPtr<TreeModel> get_model ()
> Widget* get_child ()
> So why is a smart pointer used for get_model(), but not for
> get_child(). Is there a reason behind? Could someone please explain
there are some resources in GTK/GDK whose lifetime needs to be managed
more "carefully" than everything else. these are generally accessed in
gtkmm using RefPtr.
basically, if the gtkmm API gives you back a RefPtr, you should accept
that there is a good reason for it and move on. don't bother using
RefPtr for any other cases, and almost certainly don't use it for your
own (non-gtkmm-derived) objects.
] [Thread Prev