From 2f5012e38cd6566d01b98fb44679c9b431dbd473 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 7 May 2009 18:39:07 +0100 Subject: [PATCH] [animation] Do not leak timelines The timeline created when calling set_timeline(NULL) is referenced even though we implicitly own it. When the Animation is destroyed, the timeline is then leaked. Thanks to: Richard Heatley Fixes bug: http://bugzilla.openedhand.com/show_bug.cgi?id=1548 --- clutter/clutter-animation.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/clutter/clutter-animation.c b/clutter/clutter-animation.c index d835694b4..6eb7d85f3 100644 --- a/clutter/clutter-animation.c +++ b/clutter/clutter-animation.c @@ -1115,12 +1115,12 @@ clutter_animation_set_timeline (ClutterAnimation *animation, priv = animation->priv; - if (timeline && priv->timeline == timeline) + if (timeline != NULL && priv->timeline == timeline) return; g_object_freeze_notify (G_OBJECT (animation)); - if (priv->timeline) + if (priv->timeline != NULL) { if (priv->timeline_started_id) g_signal_handler_disconnect (priv->timeline, @@ -1136,13 +1136,17 @@ clutter_animation_set_timeline (ClutterAnimation *animation, priv->timeline = 0; } - if (!timeline) - timeline = g_object_new (CLUTTER_TYPE_TIMELINE, - "duration", priv->duration, - "loop", priv->loop, - NULL); + if (timeline == NULL) + { + timeline = g_object_new (CLUTTER_TYPE_TIMELINE, + "duration", priv->duration, + "loop", priv->loop, + NULL); + } else { + g_object_ref (timeline); + priv->duration = clutter_timeline_get_duration (timeline); g_object_notify (G_OBJECT (animation), "duration"); @@ -1150,7 +1154,7 @@ clutter_animation_set_timeline (ClutterAnimation *animation, g_object_notify (G_OBJECT (animation), "loop"); } - priv->timeline = g_object_ref (timeline); + priv->timeline = timeline; g_object_notify (G_OBJECT (animation), "timeline"); priv->timeline_started_id =