[animation] Keep a reference during notify::alpha
authorEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 8 Jun 2009 13:42:22 +0000 (14:42 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 8 Jun 2009 13:42:22 +0000 (14:42 +0100)
The Animation should be referenced during the notification of the
alpha value, since the callback is invoked depending on the Alpha
and it won't vivify the Animation instance for us.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1537

clutter/clutter-animation.c

index fc20fdf..e0c20a8 100644 (file)
@@ -777,12 +777,17 @@ on_alpha_notify (GObject          *gobject,
                  GParamSpec       *pspec,
                  ClutterAnimation *animation)
 {
-  ClutterAnimationPrivate *priv = animation->priv;
+  ClutterAnimationPrivate *priv;
   GList *properties, *p;
   gdouble alpha_value;
   gboolean is_animatable = FALSE;
   ClutterAnimatable *animatable = NULL;
 
+  /* make sure the animation survives the notification */
+  g_object_ref (animation);
+
+  priv = animation->priv;
+
   alpha_value = clutter_alpha_get_alpha (CLUTTER_ALPHA (gobject));
 
   if (CLUTTER_IS_ANIMATABLE (priv->object))
@@ -835,6 +840,8 @@ on_alpha_notify (GObject          *gobject,
   g_list_free (properties);
 
   g_object_thaw_notify (priv->object);
+
+  g_object_unref (animation);
 }
 
 static ClutterAlpha *