Index: ui/compositor/layer_animator.cc |
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc |
index 5fc289b42c79868d2d8f2a161b1db0595eb381be..9213995d417bdf06da2cbb88c07c97d7cd251468 100644 |
--- a/ui/compositor/layer_animator.cc |
+++ b/ui/compositor/layer_animator.cc |
@@ -43,13 +43,16 @@ LayerAnimator::LayerAnimator(base::TimeDelta transition_duration) |
transition_duration_(transition_duration), |
tween_type_(Tween::LINEAR), |
is_started_(false), |
- disable_timer_for_test_(false) { |
+ disable_timer_for_test_(false), |
+ destroyed_(NULL) { |
} |
LayerAnimator::~LayerAnimator() { |
for (size_t i = 0; i < running_animations_.size(); ++i) |
running_animations_[i].sequence->OnAnimatorDestroyed(); |
ClearAnimations(); |
+ if (destroyed_) |
+ *destroyed_ = true; |
} |
// static |
@@ -235,13 +238,16 @@ void LayerAnimator::StopAnimatingProperty( |
RunningAnimation* running = GetRunningAnimation(property); |
if (!running) |
break; |
- FinishAnimation(running->sequence); |
+ if (FinishAnimation(running->sequence) == DESTROYED) |
+ return; |
} |
} |
void LayerAnimator::StopAnimating() { |
- while (is_animating()) |
- FinishAnimation(running_animations_[0].sequence); |
+ while (is_animating()) { |
+ if (FinishAnimation(running_animations_[0].sequence) == DESTROYED) |
+ return; |
+ } |
} |
void LayerAnimator::AddObserver(LayerAnimationObserver* observer) { |
@@ -293,10 +299,12 @@ void LayerAnimator::Step(base::TimeTicks now) { |
base::TimeDelta delta = now - running_animations_copy[i].start_time; |
if (delta >= running_animations_copy[i].sequence->duration() && |
!running_animations_copy[i].sequence->is_cyclic()) { |
- FinishAnimation(running_animations_copy[i].sequence); |
+ if (FinishAnimation(running_animations_copy[i].sequence) == DESTROYED) |
+ return; |
needs_redraw = true; |
- } else if (ProgressAnimation(running_animations_copy[i].sequence, delta)) |
+ } else if (ProgressAnimation(running_animations_copy[i].sequence, delta)) { |
needs_redraw = true; |
+ } |
} |
if (needs_redraw && delegate()) |
@@ -356,11 +364,20 @@ LayerAnimationSequence* LayerAnimator::RemoveAnimation( |
return to_return.release(); |
} |
-void LayerAnimator::FinishAnimation(LayerAnimationSequence* sequence) { |
+LayerAnimator::DestroyedType LayerAnimator::FinishAnimation( |
+ LayerAnimationSequence* sequence) { |
scoped_ptr<LayerAnimationSequence> removed(RemoveAnimation(sequence)); |
- sequence->Progress(sequence->duration(), delegate()); |
+ { |
+ bool destroyed = false; |
+ destroyed_ = &destroyed; |
+ sequence->Progress(sequence->duration(), delegate()); |
+ if (destroyed) |
+ return DESTROYED; |
+ destroyed_ = NULL; |
+ } |
ProcessQueue(); |
UpdateAnimationState(); |
+ return NOT_DESTROYED; |
} |
void LayerAnimator::FinishAnyAnimationWithZeroDuration() { |