listbox: Unbind the model before removing children
authorEmmanuele Bassi <ebassi@gnome.org>
Tue, 4 Apr 2023 12:40:49 +0000 (13:40 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Tue, 4 Apr 2023 12:47:36 +0000 (13:47 +0100)
commitfb3f817f693b5484eaf186b9517b01a986fc2c0d
treebb0f342594f35c187c5773724cfdf20c61249728
parent231b12124e79cbfedd211c673a3ebf80d0f3bccc
listbox: Unbind the model before removing children

Calling gtk_list_box_remove_all() is a no-op with a bound model; after
the introduction of the remove_all() method in 49e56fc7, we were left
with row widgets after the dispose() call chained up.

We could restore the explicit unparenting inside dispose() instead of
calling remove_all(), but since the bound list model is provided by the
user of GtkListBox, it's more appropriate to unbind it in the dispose()
implementation, to avoid any potential reference cycle (especially in
higher level languages that have no explicit reference acquisition).

We clean up the bound model, and its associated state, if any; and then
we remove all the row widgets that are left.
gtk/gtklistbox.c