Skip to content
  • Emmanuele Bassi's avatar
    animation: Use ::destroy with animate() · 57ebce80
    Emmanuele Bassi authored
    ClutterAnimation uses the weak ref machinery of GObject when associated
    to ClutterActor by clutter_actor_animate() and friends - all the while
    taking a reference on the actor itself. In order to trigger the weak ref
    callback, external code would need to unref the Actor at least twice,
    which has slim chance of happening. Plus, the way to destroy an Actor is
    to call destroy(), not call unref().
    
    The destruction sequence of ClutterActor emits the ::destroy signal, which
    should be used by classes to release external references the might be
    holding. My oh my, this sounds *exactly* the case!
    
    So, let's switch to using the ::destroy signal for clutter_actor_animate()
    and friends, since we know that the object bound to the Animation is
    an Actor, and has a ::destroy signal.
    
    This change has the added benefit of allowing destroying an actor as the
    result of the Animation::completed signal without getting a segfault or
    other bad things to happen.
    
    Obviously, the change does not affect other GObject classes, or Animation
    instances created using clutter_animation_new(); for those, the current
    "let's take a reference on the object to avoid it going away in-flight"
    mechanism should still suffice.
    
    Side note: it would be interesting if GObject had an interface for
    "destructible" objects, so that we could do a safe type check. I guess
    it's a Rainy Day Project(tm)...
    57ebce80