2008/7/23 Julien Langer <[EMAIL PROTECTED]>:

>
> 2008/7/23 Murray Cumming <[EMAIL PROTECTED]>:
>
>> On Wed, 2008-07-23 at 12:12 +0200, Julien Langer wrote:
>> > 2008/7/23 Murray Cumming <[EMAIL PROTECTED]>:
>> >
>> >         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.
>>
>> Again, I don't think that's true, or that it should be true. Do you have
>> 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 call 
> gtk_widget_destroy()<http://library.gnome.org/devel/gtk/stable/GtkWidget.html#gtk-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.
>

Ok here's a minimal example:

main.cpp:

struct MyHBox : public Gtk::HBox
{
    MyHBox(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>&
builder)
        : Gtk::HBox(cobject) {}

    ~MyHBox()
    {
        std::cout << "deleted" << std::endl;
    }
};

int main(int argc, char* argv[])
{
    Gtk::Main kit(argc, argv);
    Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_file(
"test.ui" );

    MyHBox *box;
    builder->get_widget_derived( "hbox", box );
}

test.ui:
<interface>
<object class="GtkHBox" id="hbox">
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</object>
</interface>


>
>
>>
>> > 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)
>>
>>
>> --
>> [EMAIL PROTECTED]
>> www.murrayc.com
>> www.openismus.com
>>
>>
>
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to