From: Matthias Clasen Date: Wed, 25 Dec 2019 01:06:57 +0000 (-0500) Subject: widget: Avoid a crash in event handling X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~20^2~500 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a02e25ffffd3d66bb7bc19d649f41efb130b7ae6;p=gtk4.git widget: Avoid a crash in event handling I was seeing crashes in gtk_widget_run_controllers. We were accessing the controller after calling out to application code that might remove it. Better be safe and do the access before. --- diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index dadee32823..1c03acb20f 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5207,14 +5207,22 @@ gtk_widget_run_controllers (GtkWidget *widget, controller_phase = gtk_event_controller_get_propagation_phase (controller); if (controller_phase == phase) - handled |= gtk_event_controller_handle_event (controller, event); + { + gboolean this_handled; + gboolean is_gesture; - /* Non-gesture controllers are basically unique entities not meant - * to collaborate with anything else. Break early if any such event - * controller handled the event. - */ - if (handled && !GTK_IS_GESTURE (controller)) - break; + is_gesture = GTK_IS_GESTURE (controller); + this_handled = gtk_event_controller_handle_event (controller, event); + + handled |= this_handled; + + /* Non-gesture controllers are basically unique entities not meant + * to collaborate with anything else. Break early if any such event + * controller handled the event. + */ + if (this_handled && !is_gesture) + break; + } } l = next;