On Tue, 03 Sep 2013 09:40:19 +0200
Murray Cumming <murr...@murrayc.com> wrote:
> On Mon, 2013-09-02 at 16:13 +0200, Krzysztof Kosiński wrote:
> > 2013/9/2 Kjell Ahlstedt <kjell.ahlst...@bredband.net>:
> > > Objects of classes that derive from Gtk::Object are not put in
> > > Glib::RefPtr<>s. I'm not sure why.
> > 
> > I'm also a little confused by this but it probably has something to
> > do with Gtk::manage().
> 
> GtkWidgets don't use simple reference counting in the GTK+ C API. They
> can be destroyed at any time regardless of the reference count. So we
> can't use RefPtr with them easily.

That is not really true.  widgets are always (and only) destroyed when
their sunk reference count reaches 0, and incrementing the reference
count before removing a widget from a container is how you move them
between containers. There is no problem with holding a non-top level
widget by RefPtr provided you call g_object_ref() on the C object
first, which is inconvenient with gtkmm and leaves the opportunity to
forget to do so. So it is inadvisable.

With top level windows it would be highly confusing to take your own
reference in this way.  You expect a top level window to disappear when
you call gtk_widget_destroy() on it to drop GTK+'s top level reference,
not hang around.

Chris
_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to