Re: Equivalent of the gtk g_object_ref/unref functions in gtkmm?



On Mon, 2007-03-26 at 15:50 +0200, Jef Driesen wrote:
> > This page has an overview of gtkmm memory management:
> > http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch22.html
> > 
> > In summary, it's just regular C++ memory management so you can do what
> > you like, and we have some things to help you sometimes.
> 
> Thanks for the clarification.
> 
> >> One of the problems I'm trying to solve is I want to create a treeview 
> >> that will act as a sidebar pane in my application. And I would like to 
> >> store a reference to other widgets (which are in a notebook) in the 
> >> treemodel. When the user activates an item in the treeview, the 
> >> corresponding widget should be displayed in the main application pane 
> >> (by displaying the correct notebook page). How should this treemodel 
> >> look like in gtkmm? Is a smart pointer going to interfere with the 
> >> automatic memory management when I add the widget to the notebook? Do I 
> >> need smart pointers at all for all this?
> > 
> > You can use some other smartpointer, such as one from boost, or you can
> > use some parent-child relationship of your own.
> 
> What do you mean with "parent-child relationship"?

You can decide to "give" ownership of a child widget to a parent widget,
so that the child is only destroyed when the parent widget does not need
it any more. Reference-counting is useful when no such simple ownership
make sense.

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




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