Commit a37976da authored by Tristan Van Berkom's avatar Tristan Van Berkom

Fixed GtkToolPalette ->forall implementation to be gtk_widget_destroy friendly

The forall() loop was buggy as it was skipping items in the list when
the current item gets removed from the groups array as a result of
calling the callback (causing memory leaks).
parent ddb4b3eb
......@@ -831,15 +831,21 @@ gtk_tool_palette_forall (GtkContainer *container,
gpointer callback_data)
GtkToolPalette *palette = GTK_TOOL_PALETTE (container);
guint i;
guint i, len;
for (i = 0; i < palette->priv->groups->len; ++i)
GtkToolItemGroupInfo *info = g_ptr_array_index (palette->priv->groups, i);
len = palette->priv->groups->len;
if (info->widget)
callback (GTK_WIDGET (info->widget),
/* At destroy time, 'callback' results in removing a widget,
* here we just reset the current index to account for the removed widget. */
i -= (len - palette->priv->groups->len);
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