{
Panels *panels;
GtkWidget *child;
- GList *children;
+ GList *children, *next;
g_return_if_fail(container != NULL);
g_return_if_fail(IS_PANELS(container));
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)
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));