[gtk/popover-menu-custom-child] Tweak memory management for custom slots
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/popover-menu-custom-child] Tweak memory management for custom slots
- Date: Wed, 21 Oct 2020 16:42:22 +0000 (UTC)
commit 4d8f7bcb41a13c5a65e085c123094719fd429507
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Oct 21 11:56:54 2020 -0400
Tweak memory management for custom slots
Having the slot id available on the widget will
be useful in the next commit.
gtk/gtkmenusectionbox.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkmenusectionbox.c b/gtk/gtkmenusectionbox.c
index a46420fc32..a2ae4bdd03 100644
--- a/gtk/gtkmenusectionbox.c
+++ b/gtk/gtkmenusectionbox.c
@@ -354,7 +354,11 @@ gtk_menu_section_box_insert_func (GtkMenuTrackerItem *item,
if (g_hash_table_lookup (box->custom_slots, id))
g_warning ("Duplicate custom ID: %s", id);
else
- g_hash_table_insert (box->custom_slots, g_strdup (id), widget);
+ {
+ char *slot_id = g_strdup (id);
+ g_object_set_data_full (G_OBJECT (widget), "slot-id", slot_id, g_free);
+ g_hash_table_insert (box->custom_slots, slot_id, widget);
+ }
}
else
{
@@ -517,7 +521,7 @@ gtk_menu_section_box_new_toplevel (GtkPopoverMenu *popover,
box = g_object_new (GTK_TYPE_MENU_SECTION_BOX, NULL);
box->indicators = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- box->custom_slots = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ box->custom_slots = g_hash_table_new (g_str_hash, g_str_equal);
box->flags = flags;
gtk_popover_menu_add_submenu (popover, GTK_WIDGET (box), "main");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]