Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure we unsubscribe from PropertyChanged in AnimationInstance #6072

Merged
merged 5 commits into from
Jun 17, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Avalonia.Animation/AnimationInstance`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ public AnimationInstance(Animation animation, Animatable control, Animator<T> an
_onCompleteAction = OnComplete;
_interpolator = Interpolator;
_baseClock = baseClock;
control.PropertyChanged += ControlPropertyChanged;

UpdateNeutralValue();
FetchProperties();
}

Expand Down Expand Up @@ -82,6 +79,7 @@ protected override void Unsubscribed()
// Animation may have been stopped before it has finished.
ApplyFinalFill();

_targetControl.PropertyChanged -= ControlPropertyChanged;
grokys marked this conversation as resolved.
Show resolved Hide resolved
_timerSub?.Dispose();
_clock.PlayState = PlayState.Stop;
}
Expand All @@ -90,6 +88,8 @@ protected override void Subscribed()
{
_clock = new Clock(_baseClock);
_timerSub = _clock.Subscribe(Step);
_targetControl.PropertyChanged += ControlPropertyChanged;
UpdateNeutralValue();
}

public void Step(TimeSpan frameTick)
Expand Down