Re: reference pointer in the custom container (was: Re: preferred way to destroy a window)



On Sat, 2006-08-05 at 00:07 +0300, Paul Pogonyshev wrote:
> Murray Cumming wrote:
> 
> > Glib::RefPtr is not for use with widgets. It is for use with classes that
> > do not allow you to use them without RefPtr. See the gtkmm book for more
> > detailed documentaiton. If you did use it then you would have to be a lot
> > more careful about whether or not it had a starting reference.
> 
> In plain GTK+ it is common to reference a widget to make sure it is not
> destroyed before the reference keeper.

This is not necessary with gtkmm. Containers do not destroy their child
widgets by default.

>   And widgets are not different from
> other objects in this respect.
> 
> > If what you actually want is for the child to be deleted automatically
> > when the window is deleted, then just use Gtk::manage(). Again, this is in
> > gtkmm book.
> > http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch03s02.html
> > and
> > http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch20.html
> >
> > Do make sure you've read that Basics chapter. It will save you lots of time.
> 
> I have read the books.  It says nothing about how the manage() works

This is not true. Both the basics chapter and the memory management
chapter say what it does.

>  and I
> assumed all the way that it destroys C++ object when underlying C object's
> reference count drops to zero i.e. when C object is destroyed.  In this case,
> an additional RefPtr shouldn't hurt, but apparently it does.  And I consider
> it wrong.
> 
> Anyway, RefPtr is not very important in _this_ case.
> 
> Paul

-- 
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]