mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 19:30:10 +00:00
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).
This commit is contained in:
parent
ddb4b3ebe2
commit
a37976dae0
@ -831,15 +831,21 @@ gtk_tool_palette_forall (GtkContainer *container,
|
|||||||
gpointer callback_data)
|
gpointer callback_data)
|
||||||
{
|
{
|
||||||
GtkToolPalette *palette = GTK_TOOL_PALETTE (container);
|
GtkToolPalette *palette = GTK_TOOL_PALETTE (container);
|
||||||
guint i;
|
guint i, len;
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < palette->priv->groups->len; ++i)
|
for (i = 0; i < palette->priv->groups->len; ++i)
|
||||||
{
|
{
|
||||||
GtkToolItemGroupInfo *info = g_ptr_array_index (palette->priv->groups, i);
|
GtkToolItemGroupInfo *info = g_ptr_array_index (palette->priv->groups, i);
|
||||||
|
|
||||||
|
len = palette->priv->groups->len;
|
||||||
|
|
||||||
if (info->widget)
|
if (info->widget)
|
||||||
callback (GTK_WIDGET (info->widget),
|
callback (GTK_WIDGET (info->widget),
|
||||||
callback_data);
|
callback_data);
|
||||||
|
|
||||||
|
/* 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user