Re: Which widgets require a RefPtr



On Sun, 2008-07-27 at 12:22 +0900, Ryan McDougall wrote:
> Reading the documentation here:
> http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-memory-shared-resources.html
> 
> It says that "some" objects need the RefPtr, and indeed looking at the
> code it would seem that some Gtk:: objects do use RefPtr,

Anything that can't be constructed without a create*() method needs a
RefPtr, and you are forced to use a RefPtr, so there's not much room for
confusion.

>  where others
> are naked (presumably left up to me to decide what to do with their
> memory).
> Ex:    Gtk::VBox packingbox_;
>         Glib::RefPtr<Gtk::UIManager> uimanager_;
>         Glib::RefPtr<Gtk::ActionGroup> actiongroup_;
> 
> Is there a canonical list of which widgets do and don't?

No, but how would this be useful? Just do what the class forces you to
do.

> I would appear that Glib::ObjectBase defines reference(), so does that
> mean that all derived objects should go through RefPtr?

No, things that derive from Gtk::Object cannot use simple
reference-counting.

-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com



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