[libdazzle] menus: separate item extraction from destruction
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] menus: separate item extraction from destruction
- Date: Sat, 21 Jul 2018 19:50:40 +0000 (UTC)
commit 690912445d495e332730eae006a360b802e3e6bd
Author: Christian Hergert <chergert redhat com>
Date: Sat Jul 21 12:49:58 2018 -0700
menus: separate item extraction from destruction
To be more defensive here, we can save our own list of children with a
full reference while we destroy the items. Then perform finalize unref
and list free after we have marked the widgets as destroyed.
src/menus/dzl-menu-button.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/menus/dzl-menu-button.c b/src/menus/dzl-menu-button.c
index 226017c..5dcda9a 100644
--- a/src/menus/dzl-menu-button.c
+++ b/src/menus/dzl-menu-button.c
@@ -119,6 +119,7 @@ dzl_menu_button_items_changed (DzlMenuButton *self,
GMenuModel *menu)
{
DzlMenuButtonPrivate *priv = dzl_menu_button_get_instance_private (self);
+ GList *children = NULL;
g_assert (DZL_IS_MENU_BUTTON (self));
g_assert (G_IS_MENU_MODEL (menu));
@@ -126,10 +127,12 @@ dzl_menu_button_items_changed (DzlMenuButton *self,
for (guint i = 0; i < removed; i++)
{
GtkWidget *child = dzl_box_get_nth_child (priv->popover_box, position);
-
- gtk_widget_destroy (child);
+ children = g_list_prepend (children, g_object_ref (child));
}
+ g_list_foreach (children, (GFunc)gtk_widget_destroy, NULL);
+ g_list_free_full (children, g_object_unref);
+
for (guint i = position; i < (position + added); i++)
{
g_autofree gchar *label = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]