gtklistbox: Only unparent header rows if they haven’t been reused
authorPhilip Withnall <withnall@endlessm.com>
Fri, 4 Oct 2019 17:25:34 +0000 (18:25 +0100)
committerPhilip Withnall <withnall@endlessm.com>
Fri, 4 Oct 2019 17:48:53 +0000 (18:48 +0100)
commitb70f389b6418ec953c6995f36ff0c3ad0e26ddc3
tree62ca07dbf6f76e826c9d763a6b5a388992f3700e
parent1c73edd9b0bffdd41ebb010a09037a6aacfb09b2
gtklistbox: Only unparent header rows if they haven’t been reused

It’s possible for code which uses a `GtkListBox` to reuse a single
header row, and move it around between rows. For example, this might
happen if the code has interactive widgets (like buttons) in the row,
and doesn’t want to continually recreate them and reattach signals to
them whenever the row headers change.

Unfortunately, this was broken, as the old header widget was
unconditionally unparented, even if it had just been set as the header
for a different row in the same `GtkListBox`. This left it assigned as
a child widget in the `GtkListBox` (so it was iterated over by
`forall`), but without its parent widget set.

Fix that by only unparenting the header if it hasn’t already been
assigned as the parent of a different row.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
gtk/gtklistbox.c