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.
This commit is contained in:
Matthias Clasen 2019-12-24 20:06:57 -05:00
parent 280bdb0567
commit a02e25ffff

View File

@ -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;