Finalizing XXX, but it still has children left, when using Builder UI XML

I am building a reasonably sized GUI using Rust Gtk and using XML .ui files to define my interface. I was having a problem that as I partitioned the UI into many files (approx 16) I kept getting warning messages, when closing my windows, that said

Finalizing MySubClass, but it still has children left,

Searching the web provided no answers, but I did find the cause.
My Subclasses were all subclassing GtkWidget, changing this to GtkBox removed the warnings.
Obvious now that I know, GtkWidget does not remove its children, but GtkBox will do just that.

If you are subclassing GtkWidget then you have the responsibility to remove the widgets you added. That is done in the dispose() virtual function.

For template widgets, you can call gtk_widget_dispose_template(); for widgets added manually through gtk_widget_set_parent() you will need to call gtk_widget_unparent().

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.