[gtk/wip/otte/for-master: 5/5] listitemmanager: Do a better job on double items
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/for-master: 5/5] listitemmanager: Do a better job on double items
- Date: Thu, 16 Jul 2020 18:44:07 +0000 (UTC)
commit de56e892aaecfe6f338a35177b255e127569b2d5
Author: Benjamin Otte <otte redhat com>
Date: Sun Jul 12 07:49:53 2020 +0200
listitemmanager: Do a better job on double items
Previously, we would unparent the existing item that we were about
to reuse, and not the duplicate one.
Change that.
gtk/gtklistitemmanager.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtklistitemmanager.c b/gtk/gtklistitemmanager.c
index 34c52e48bd..7cad397ffa 100644
--- a/gtk/gtklistitemmanager.c
+++ b/gtk/gtklistitemmanager.c
@@ -577,13 +577,11 @@ gtk_list_item_manager_model_items_changed_cb (GListModel *model,
GtkListItemManager *self)
{
GHashTable *change;
- GHashTableIter iter;
- gpointer list_item;
GSList *l;
guint n_items;
n_items = g_list_model_get_n_items (G_LIST_MODEL (self->model));
- change = g_hash_table_new (g_direct_hash, g_direct_equal);
+ change = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify )gtk_widget_unparent);
gtk_list_item_manager_remove_items (self, change, position, removed);
gtk_list_item_manager_add_items (self, position, added);
@@ -727,12 +725,6 @@ gtk_list_item_manager_model_items_changed_cb (GListModel *model,
tracker->widget = GTK_LIST_ITEM_WIDGET (item->widget);
}
- g_hash_table_iter_init (&iter, change);
- while (g_hash_table_iter_next (&iter, NULL, &list_item))
- {
- gtk_list_item_manager_release_list_item (self, NULL, list_item);
- }
-
g_hash_table_unref (change);
gtk_widget_queue_resize (self->widget);
@@ -1073,10 +1065,12 @@ gtk_list_item_manager_release_list_item (GtkListItemManager *self,
if (change != NULL)
{
- if (g_hash_table_insert (change, gtk_list_item_widget_get_item (GTK_LIST_ITEM_WIDGET (item)), item))
- return;
-
- g_warning ("FIXME: Handle the same item multiple times in the list.\nLars says this totally should not
happen, but here we are.");
+ if (!g_hash_table_replace (change, gtk_list_item_widget_get_item (GTK_LIST_ITEM_WIDGET (item)), item))
+ {
+ g_warning ("FIXME: Handle the same item multiple times in the list.\nLars says this totally should
not happen, but here we are.");
+ }
+
+ return;
}
gtk_widget_unparent (item);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]