Skip to content
Snippets Groups Projects
Commit e9e8adda authored by Adrien Plazas's avatar Adrien Plazas Committed by Guido Gunther
Browse files

leaflet: Allow editing the children list when looping through it

This avoids potential crashes when destroying a leaflet and this avoids
leaks as not all children where looped through as the children list was
edited while being looped through when destroying the leaflet.

This fixes #42.
parent b6213b5c
No related branches found
No related tags found
1 merge request!177leaflet: Clear the children list on disposal
Pipeline #2592 passed
......@@ -2265,10 +2265,15 @@ hdy_leaflet_forall (GtkContainer *container,
{
HdyLeaflet *self = HDY_LEAFLET (container);
HdyLeafletPrivate *priv = hdy_leaflet_get_instance_private (self);
/* This shallow copy is needed when the callback changes the list while we are
* looping through it, for example by calling hdy_leaflet_remove() on all
* children when destroying the HdyLeaflet_private_offset.
*/
g_autoptr (GList) children_copy = g_list_copy (priv->children);
GList *children;
HdyLeafletChildInfo *child_info;
for (children = priv->children; children; children = children->next) {
for (children = children_copy; children; children = children->next) {
child_info = children->data;
(* callback) (child_info->widget, callback_data);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment