0

Dispose tempalte disposes only bound widgets. Is there a way to dispose all children graph?

Here are the details.

Object implementation:

    #[derived_properties]
    impl ObjectImpl for MyWidget {
        fn constructed(&self) {
            self.parent_constructed();
        }

        fn dispose(&self) {
            self.dispose_template();
        }
    }

Template:

<?xml version="1.0" encoding="UTF-8"?>
<interface>
    <template class="MyWidget" parent="GtkWidget">
        <property name="layout-manager">
            <object class="GtkBoxLayout">
                <property name="orientation">vertical</property>
                <property name="spacing">12</property>
            </object>
        </property>

        <child>
            <object class="GtkLabel" id="label">
                <style><class name="title-3"/></style>
                <property name="label" bind-source="MyWidget" bind-property="text" bind-flags="sync-create" />
                <property name="vexpand">true</property>
            </object>
        </child>

        <child>
            <object class="GtkBox">
                <style><class name="pink"/></style>
                <child>
                    <object class="GtkSpinner" id="spinner">
                        <property name="halign">center</property>
                        <property name="valign">center</property>
                        <property name="hexpand">true</property>
                        <property name="vexpand">true</property>
                        <property name="width-request">48</property>
                        <property name="height-request">48</property>

                        <property name="spinning">true</property>
                    </object>
                </child>
            </object>
        </child>
    </template>
</interface>

There are three widgets on a template

  1. GtkLabel bound to field "label" - disposed
  2. GtkBox - not bound to field, not disposed (this one is the problem)
  3. GtkSpinner - bound to field "spinner" - dispsed

I'd expect dispose_template will dispose all children.

Do I really have to have backing field for every widget mentioned on template? or I'm missing something

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.