Re: [sigc] conditions in libsigc
- From: Murray Cumming <murrayc murrayc com>
- To: Chris Vine <chris cvine freeserve co uk>
- Cc: libsigc-list gnome org, Paul Pogonyshev <pogonyshev gmx net>
- Subject: Re: [sigc] conditions in libsigc
- Date: Fri, 07 Jul 2006 18:09:26 +0200
On Thu, 2006-07-06 at 21:55 +0100, Chris Vine wrote:
> On Thursday 06 July 2006 21:44, Chris Vine wrote:
> >
> > Glib::RefPtr is designed to reference objects derived from GObject (sorry,
> > I can't remember their glibmm class designation, probably Glib::Object) but
> > not from GtkObject (Gtk::Object). Classes derived from Gtk::Object are
> > owned by the container in which they are placed, if you provide they are to
> > be managed (as you did). If you assign them to a Glib::RefPtr you will
> > need to increment the reference count when doing so in order to pass
> > ownership to the Glib::RefPtr smart pointer. If you don't have them as
> > managed objects, you don't need to increment the reference count (but you
> > may have to call gtk_object_sink() on them to eliminate the floating
> > reference - I am not sure whether you need to do this in gtkmm because I
> > either use the raw C objects or, with gtkmm, have them managed by the
> > container).
>
> Actually I am not sure if I am right about the last sentence - it is true with
> GTK+ (with C objects) but I am not sure about gtkmm - you probably need to
> call delete on the gtkmm object at some stage if it is not managed by the
> container, since bringing the reference count to 0 will cause the underlying
> C object to be destroyed but not the C++ superstructure on top. The best
> rule is never to use Glib::RefPtr with objects derived from Gtk::Object.
Your conclusion is correct.
http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch18.html
--
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]