clutter/action: Take a ref on actions during event handling

ClutterStage will unref an action in the middle of its own event handler in
case the action causes its own actor to be destroyed. In this case the
action would get freed underneath our feet. To avoid it, take a ref on the
action while calling its handle_event() vfunc, just as we do in
clutter_actor_event() while emitting an event to an actor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2389>
This commit is contained in:
Jonas Dreßler 2023-02-09 01:45:38 +01:00
parent a1381ea6bc
commit 05cb4a4443

View File

@ -99,7 +99,13 @@ gboolean
clutter_action_handle_event (ClutterAction *action,
const ClutterEvent *event)
{
return CLUTTER_ACTION_GET_CLASS (action)->handle_event (action, event);
gboolean retval;
g_object_ref (action);
retval = CLUTTER_ACTION_GET_CLASS (action)->handle_event (action, event);
g_object_unref (action);
return retval;
}
void