2008/7/23 Murray Cumming <murrayc murrayc com>:On Wed, 2008-07-23 at 12:12 +0200, Julien Langer wrote:Again, I don't think that's true, or that it should be true. Do you have
> 2008/7/23 Murray Cumming <murrayc murrayc com>:
>
> I don't think that the builder should delete widgets. Do you
> have a
> simple-as-possible compileable test case that shows this? If
> so, could
> you please add it to bugzilla?
>
>
> I load the widgets that are displayed on the notebook tab from a
> GtkBuilder file.
> Multiple tabs can be opened, so I need to create a new GtkBuilder for
> each tab. (I didn't find another way to replicate the widgets created
> by the GtkBuilder).
> Each of these GtkBuilder files has a VBox with the notebook contents
> which is then added to the notebook as the child widget.
> Once the tab is closed I release the last reference to the
> RefPtr<GtkBuilder> (Of course I need to make sure that no one else
> also holds a reference to the same GtkBuilder). The GtkBuilder will
> then release the VBox.
a simple-as-possible compileable test case that shows this?
I'm currently not at home so I can't prepare an example but the documentation of the GtkBuilder says:
"A GtkBuilder holds a reference to all objects that it has constructed and drops these references when it is finalized. This finalization can cause the destruction of non-widget objects or widgets which are not contained in a toplevel window. For toplevel windows constructed by a builder, it is the responsibility of the user to callgtk_widget_destroy()
to get rid of them and all the widgets they contain. "
http://library.gnome.org/devel/gtk/stable/GtkBuilder.html
That's for plain Gtk though, the Gtkmm documentation doesn't say anything about GtkBuilder's memory management.
But that's exactly what's happening in my case since my GtkBuilder files do not contain a toplevel window.
> I first thought that the VBox is released by the notebook but then I
> realized that it's the GtkBuilder of course.
>
> It's all a big hack of course but as I said earlier I didn't find
> another clever way to replicate widgets that come from a GtkBuilder
> (I'd need something like a clone factory with the GtkBuilder providing
> the examplar objects but as far as I know widgets can't be copied or
> cloned)