From 05cb4a444310ae495e1de1b1406f01aa54eda646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Thu, 9 Feb 2023 01:45:38 +0100 Subject: [PATCH] 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: --- clutter/clutter/clutter-action.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clutter/clutter/clutter-action.c b/clutter/clutter/clutter-action.c index 9b0b7a8fb..4244721c6 100644 --- a/clutter/clutter/clutter-action.c +++ b/clutter/clutter/clutter-action.c @@ -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