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

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