summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Matos <tiagomatos@gmail.com>2017-03-02 19:18:43 +0100
committerRui Matos <tiagomatos@gmail.com>2017-03-06 13:59:48 +0100
commitcc8d61e5cf912462d051e0aad14aa362d4a6a1d8 (patch)
tree8d7ca10b444ffbb422a0fcc78f144530b6129733
parentbc567cfca7fce35c7ae4d7412d80b872a5e0a595 (diff)
downloadmutter-cc8d61e5cf912462d051e0aad14aa362d4a6a1d8.tar.gz
clutter-clone: Unset source when source actor is destroyed
Otherwise we might be holding on to a source actor that's no longer fully functioning and cause crashes if for example we try to paint it. https://bugzilla.gnome.org/show_bug.cgi?id=779483
-rw-r--r--clutter/clutter/clutter-clone.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/clutter/clutter/clutter-clone.c b/clutter/clutter/clutter-clone.c
index af03a4e81..f0eea2459 100644
--- a/clutter/clutter/clutter-clone.c
+++ b/clutter/clutter/clutter-clone.c
@@ -54,6 +54,7 @@
struct _ClutterClonePrivate
{
ClutterActor *clone_source;
+ gulong source_destroy_id;
};
G_DEFINE_TYPE_WITH_PRIVATE (ClutterClone, clutter_clone, CLUTTER_TYPE_ACTOR)
@@ -377,6 +378,13 @@ clutter_clone_new (ClutterActor *source)
}
static void
+on_source_destroyed (ClutterActor *source,
+ ClutterClone *self)
+{
+ clutter_clone_set_source_internal (self, NULL);
+}
+
+static void
clutter_clone_set_source_internal (ClutterClone *self,
ClutterActor *source)
{
@@ -387,6 +395,8 @@ clutter_clone_set_source_internal (ClutterClone *self,
if (priv->clone_source != NULL)
{
+ g_signal_handler_disconnect (priv->clone_source, priv->source_destroy_id);
+ priv->source_destroy_id = 0;
_clutter_actor_detach_clone (priv->clone_source, CLUTTER_ACTOR (self));
g_object_unref (priv->clone_source);
priv->clone_source = NULL;
@@ -396,6 +406,8 @@ clutter_clone_set_source_internal (ClutterClone *self,
{
priv->clone_source = g_object_ref (source);
_clutter_actor_attach_clone (priv->clone_source, CLUTTER_ACTOR (self));
+ priv->source_destroy_id = g_signal_connect (priv->clone_source, "destroy",
+ G_CALLBACK (on_source_destroyed), self);
}
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_SOURCE]);