X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=unix%2Fgtkpanel.c;h=591c8608df4e6b859b5d87bfaea60db7e949d426;hb=bee5812a496b6d24b6ac5bb13e8aa4de1d2f61b7;hp=c29fadef52400f0fce52350582fe25da85363459;hpb=c42085dc89b6760ab968c95bc369b03b625c3544;p=PuTTY.git diff --git a/unix/gtkpanel.c b/unix/gtkpanel.c index c29fadef..591c8608 100644 --- a/unix/gtkpanel.c +++ b/unix/gtkpanel.c @@ -225,7 +225,7 @@ static void panels_forall(GtkContainer *container, gboolean include_internals, { Panels *panels; GtkWidget *child; - GList *children; + GList *children, *next; g_return_if_fail(container != NULL); g_return_if_fail(IS_PANELS(container)); @@ -235,9 +235,19 @@ static void panels_forall(GtkContainer *container, gboolean include_internals, for (children = panels->children; children && (child = children->data); - children = children->next) + children = next) { + /* + * We can't wait until after the callback to assign + * `children = children->next', because the callback might + * be gtk_widget_destroy, which would remove the link + * `children' from the list! So instead we must get our + * hands on the value of the `next' pointer _before_ the + * callback. + */ + next = children->next; if (child) callback(child, callback_data); + } } static GtkType panels_child_type(GtkContainer *container) @@ -277,9 +287,9 @@ void panels_add(Panels *panels, GtkWidget *child) void panels_switch_to(Panels *panels, GtkWidget *target) { - GtkWidget *child; + GtkWidget *child = NULL; GList *children; - gboolean changed; + gboolean changed = FALSE; g_return_if_fail(panels != NULL); g_return_if_fail(IS_PANELS(panels));