From 3edd24fb0152789fc383568a14b38792a2c9b535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sat, 19 May 2018 23:03:32 +0200 Subject: [PATCH] widget: Properly remove event controllers in finalize We were mutating the list while iterating over it. This was not a problem before since remove_controller just set the controller pointer to NULL instead of actually removing it from the list of controllers. --- gtk/gtkwidget.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 4727e37b4d..96c7145aa6 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -8572,15 +8572,18 @@ gtk_widget_finalize (GObject *object) _gtk_size_request_cache_free (&priv->requests); - for (l = priv->event_controllers; l; l = l->next) + l = priv->event_controllers; + while (l) { + GList *next = l->next; GtkEventController *controller = l->data; if (controller) gtk_widget_remove_controller (widget, controller); + + l = next; } - g_list_free (priv->event_controllers); - priv->event_controllers = NULL; + g_assert (priv->event_controllers == NULL); if (_gtk_widget_get_first_child (widget) != NULL) {