Commit 1a1d954f authored by Christian Hergert's avatar Christian Hergert

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.
parent acd08654
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment