From 7a5c4a68c4c80b61566e6c9eeb0e854d5c344dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 27 Jul 2019 00:28:46 +0200 Subject: [PATCH 11/28] clutter/actor-meta: Unset the actor if disposed, calling the vfunc If the actor owned by an ActorMeta is destroyed we unset its pointer, however many implementations of this class keep a reference on the pointer, so we should notify them about the invalid pointer or they might try to reference an invalid memory location. Fix this by changing the destroy callback, unsetting the destroy connection id and calling _clutter_actor_meta_set_actor() https://gitlab.gnome.org/GNOME/mutter/merge_requests/682 --- clutter/clutter/clutter-actor-meta.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clutter/clutter/clutter-actor-meta.c b/clutter/clutter/clutter-actor-meta.c index 2843ea222..157c1d67e 100644 --- a/clutter/clutter/clutter-actor-meta.c +++ b/clutter/clutter/clutter-actor-meta.c @@ -56,61 +56,62 @@ struct _ClutterActorMetaPrivate guint destroy_id; gchar *name; guint is_enabled : 1; gint priority; }; enum { PROP_0, PROP_ACTOR, PROP_NAME, PROP_ENABLED, PROP_LAST }; static GParamSpec *obj_props[PROP_LAST]; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ClutterActorMeta, clutter_actor_meta, G_TYPE_INITIALLY_UNOWNED) static void on_actor_destroy (ClutterActor *actor, ClutterActorMeta *meta) { - meta->priv->actor = NULL; + meta->priv->destroy_id = 0; + _clutter_actor_meta_set_actor (meta, NULL); } static void clutter_actor_meta_real_set_actor (ClutterActorMeta *meta, ClutterActor *actor) { if (meta->priv->actor == actor) return; if (meta->priv->destroy_id != 0) { g_signal_handler_disconnect (meta->priv->actor, meta->priv->destroy_id); meta->priv->destroy_id = 0; } meta->priv->actor = actor; g_object_notify_by_pspec (G_OBJECT (meta), obj_props[PROP_ACTOR]); if (meta->priv->actor != NULL) meta->priv->destroy_id = g_signal_connect (meta->priv->actor, "destroy", G_CALLBACK (on_actor_destroy), meta); } static void clutter_actor_meta_set_property (GObject *gobject, guint prop_id, const GValue *value, GParamSpec *pspec) { -- 2.26.2