[animation] Do not connect to ::completed multiple times

The clutter_actor_animate*() family of functions should only connect
to the Animation::completed signal once, during the construction of
the Animation object attached to the Actor. Otherwise, the completed
signal handler will be run multiple times, and will try to unref()
the Animation for each call -- leading to a segmentation fault.
This commit is contained in:
Emmanuele Bassi 2009-04-05 20:32:15 +01:00
parent 6bf883da6c
commit a1cc1f57ac

View File

@ -1445,10 +1445,6 @@ clutter_animation_setupv (ClutterAnimation *animation,
&values[i], &values[i],
pspec); pspec);
} }
g_signal_connect (animation, "completed",
G_CALLBACK (on_animation_completed),
NULL);
} }
static void static void
@ -1508,10 +1504,6 @@ clutter_animation_setup_valist (ClutterAnimation *animation,
property_name = va_arg (var_args, gchar*); property_name = va_arg (var_args, gchar*);
} }
g_signal_connect (animation, "completed",
G_CALLBACK (on_animation_completed),
NULL);
} }
/** /**
@ -1562,6 +1554,11 @@ clutter_actor_animate_with_alpha (ClutterActor *actor,
if (G_LIKELY (!animation)) if (G_LIKELY (!animation))
{ {
animation = clutter_animation_new (); animation = clutter_animation_new ();
g_signal_connect (animation, "completed",
G_CALLBACK (on_animation_completed),
NULL);
CLUTTER_NOTE (ANIMATION, "Created new Animation [%p]", animation); CLUTTER_NOTE (ANIMATION, "Created new Animation [%p]", animation);
} }
else else
@ -1622,6 +1619,11 @@ clutter_actor_animate_with_timeline (ClutterActor *actor,
if (G_LIKELY (!animation)) if (G_LIKELY (!animation))
{ {
animation = clutter_animation_new (); animation = clutter_animation_new ();
g_signal_connect (animation, "completed",
G_CALLBACK (on_animation_completed),
NULL);
CLUTTER_NOTE (ANIMATION, "Created new Animation [%p]", animation); CLUTTER_NOTE (ANIMATION, "Created new Animation [%p]", animation);
} }
else else
@ -1816,6 +1818,10 @@ clutter_actor_animate (ClutterActor *actor,
clutter_animation_set_alpha (animation, NULL); clutter_animation_set_alpha (animation, NULL);
clutter_animation_set_object (animation, G_OBJECT (actor)); clutter_animation_set_object (animation, G_OBJECT (actor));
g_signal_connect (animation, "completed",
G_CALLBACK (on_animation_completed),
NULL);
CLUTTER_NOTE (ANIMATION, "Created new Animation [%p]", animation); CLUTTER_NOTE (ANIMATION, "Created new Animation [%p]", animation);
} }
else else
@ -1891,6 +1897,10 @@ clutter_actor_animatev (ClutterActor *actor,
clutter_animation_set_alpha (animation, NULL); clutter_animation_set_alpha (animation, NULL);
clutter_animation_set_object (animation, G_OBJECT (actor)); clutter_animation_set_object (animation, G_OBJECT (actor));
g_signal_connect (animation, "completed",
G_CALLBACK (on_animation_completed),
NULL);
CLUTTER_NOTE (ANIMATION, "Created new Animation [%p]", animation); CLUTTER_NOTE (ANIMATION, "Created new Animation [%p]", animation);
} }
else else
@ -1958,6 +1968,11 @@ clutter_actor_animate_with_timelinev (ClutterActor *actor,
if (G_LIKELY (!animation)) if (G_LIKELY (!animation))
{ {
animation = clutter_animation_new (); animation = clutter_animation_new ();
g_signal_connect (animation, "completed",
G_CALLBACK (on_animation_completed),
NULL);
CLUTTER_NOTE (ANIMATION, "Created new Animation [%p]", animation); CLUTTER_NOTE (ANIMATION, "Created new Animation [%p]", animation);
} }
else else
@ -2030,6 +2045,11 @@ clutter_actor_animate_with_alphav (ClutterActor *actor,
if (G_LIKELY (!animation)) if (G_LIKELY (!animation))
{ {
animation = clutter_animation_new (); animation = clutter_animation_new ();
g_signal_connect (animation, "completed",
G_CALLBACK (on_animation_completed),
NULL);
CLUTTER_NOTE (ANIMATION, "Created new Animation [%p]", animation); CLUTTER_NOTE (ANIMATION, "Created new Animation [%p]", animation);
} }
else else