state: Fix crasher when removing the last key of a transitioning state
authorChris Lord <chris@linux.intel.com>
Fri, 22 Oct 2010 14:24:49 +0000 (15:24 +0100)
committerChris Lord <chris@linux.intel.com>
Mon, 25 Oct 2010 16:21:20 +0000 (17:21 +0100)
If ClutterState is in the middle of a transition and you remove all the
keys from the target state, the target state will be destroyed without
stopping the animation/unsetting the target state. This caused an invalid
memory access.

clutter/clutter-state.c

index 493aeb0..607d429 100644 (file)
@@ -302,6 +302,10 @@ again_for_target_state:
                   /* no more keys with transitions to this target_state*/
                   if (target_state->keys == NULL)
                     {
+                      /* If this state is the current state, unset the state */
+                      if (target_state == this->priv->target_state)
+                        clutter_state_set_state (this, NULL);
+
                       /* remove any keys that exist that uses this state as a source */
                       clutter_state_remove_key (this, s->data, NULL, NULL, NULL);