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:
> 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.
--p
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]