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