Browse Source

Actually dispose DisposeAnimationInstanceSubject.

We were creating a `DisposeAnimationInstanceSubject` and then just discarding it, meaning it was never disposed.

Fixes #6111
Fixes #9514
pull/9642/head
Steven Kirk 4 years ago
parent
commit
f4eeb82a58
  1. 3
      src/Avalonia.Base/Animation/Animators/Animator`1.cs
  2. 5
      tests/Avalonia.Base.UnitTests/Animation/AnimationIterationTests.cs

3
src/Avalonia.Base/Animation/Animators/Animator`1.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using Avalonia.Animation.Utils;
using Avalonia.Collections;
@ -39,7 +40,7 @@ namespace Avalonia.Animation.Animators
VerifyConvertKeyFrames();
var subject = new DisposeAnimationInstanceSubject<T>(this, animation, control, clock, onComplete);
return match.Subscribe(subject);
return new CompositeDisposable(match.Subscribe(subject), subject);
}
protected T InterpolationHandler(double animationTime, T neutralValue)

5
tests/Avalonia.Base.UnitTests/Animation/AnimationIterationTests.cs

@ -181,7 +181,7 @@ namespace Avalonia.Base.UnitTests.Animation
Assert.Equal(border.Width, 300d);
}
[Fact(Skip = "See #6111")]
[Fact]
public void Dispose_Subscription_Should_Stop_Animation()
{
var keyframe1 = new KeyFrame()
@ -310,7 +310,7 @@ namespace Avalonia.Base.UnitTests.Animation
Assert.True(animationRun.IsCompleted);
}
[Fact(Skip = "See #6111")]
[Fact]
public void Cancellation_Should_Stop_Animation()
{
var keyframe1 = new KeyFrame()
@ -372,7 +372,6 @@ namespace Avalonia.Base.UnitTests.Animation
clock.Step(TimeSpan.FromSeconds(1));
clock.Step(TimeSpan.FromSeconds(2));
clock.Step(TimeSpan.FromSeconds(3));
//Assert.Equal(2, propertyChangedCount);
animationRun.Wait();

Loading…
Cancel
Save