Re: When using Glib::RefPtr<> and when Pointer?

On Mon, Apr 20, 2009 at 5:13 PM, Andreas Volz <lists brachttal net> wrote:
> Hello,
> I'm a little confused about the Glib::RefPtr<> usage in gtkmm.
> For some returns are used smart pointers and for some normal pointers.
> e.g.:
> Gtk::ComboBox:
> Glib::RefPtr<TreeModel>         get_model ()
> but
> Gtk::Bin:
> 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
> this?

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.


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