Blame SOURCES/0001-gtklistbox-Only-unparent-header-rows-if-they-haven-t.patch

e827ee
From 8ce68a519414df141e3de7432ab4d55564e933a0 Mon Sep 17 00:00:00 2001
e827ee
From: Philip Withnall <withnall@endlessm.com>
e827ee
Date: Fri, 4 Oct 2019 18:25:34 +0100
e827ee
Subject: [PATCH] =?UTF-8?q?gtklistbox:=20Only=20unparent=20header=20rows?=
e827ee
 =?UTF-8?q?=20if=20they=20haven=E2=80=99t=20been=20reused?=
e827ee
MIME-Version: 1.0
e827ee
Content-Type: text/plain; charset=UTF-8
e827ee
Content-Transfer-Encoding: 8bit
e827ee
e827ee
It’s possible for code which uses a `GtkListBox` to reuse a single
e827ee
header row, and move it around between rows. For example, this might
e827ee
happen if the code has interactive widgets (like buttons) in the row,
e827ee
and doesn’t want to continually recreate them and reattach signals to
e827ee
them whenever the row headers change.
e827ee
e827ee
Unfortunately, this was broken, as the old header widget was
e827ee
unconditionally unparented, even if it had just been set as the header
e827ee
for a different row in the same `GtkListBox`. This left it assigned as
e827ee
a child widget in the `GtkListBox` (so it was iterated over by
e827ee
`forall`), but without its parent widget set.
e827ee
e827ee
Fix that by only unparenting the header if it hasn’t already been
e827ee
assigned as the parent of a different row.
e827ee
e827ee
Signed-off-by: Philip Withnall <withnall@endlessm.com>
e827ee
---
e827ee
 gtk/gtklistbox.c | 5 ++++-
e827ee
 1 file changed, 4 insertions(+), 1 deletion(-)
e827ee
e827ee
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
e827ee
index 36f9ec5246..db3ec5cbb8 100644
e827ee
--- a/gtk/gtklistbox.c
e827ee
+++ b/gtk/gtklistbox.c
e827ee
@@ -2426,8 +2426,11 @@ gtk_list_box_update_header (GtkListBox    *box,
e827ee
                                 priv->update_header_func_target);
e827ee
       if (old_header != ROW_PRIV (row)->header)
e827ee
         {
e827ee
-          if (old_header != NULL)
e827ee
+          if (old_header != NULL &&
e827ee
+              g_hash_table_lookup (priv->header_hash, old_header) == row)
e827ee
             {
e827ee
+              /* Only unparent the @old_header if it hasn’t been re-used as the
e827ee
+               * header for a different row. */
e827ee
               gtk_widget_unparent (old_header);
e827ee
               g_hash_table_remove (priv->header_hash, old_header);
e827ee
             }
e827ee
-- 
e827ee
2.18.2
e827ee