mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 05:22:54 +08:00
Fix samples not being disposed
This commit is contained in:
parent
e44a8b3934
commit
261ddd2b4a
@ -10,6 +10,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.TypeExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Threading;
|
||||
@ -126,6 +127,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
[CanBeNull]
|
||||
private HitObjectLifetimeEntry lifetimeEntry;
|
||||
|
||||
private Container<PausableSkinnableSound> samplesContainer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
@ -142,6 +145,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
config.BindWith(OsuSetting.PositionalHitSounds, userPositionalHitSounds);
|
||||
|
||||
// Explicit non-virtual function call.
|
||||
base.AddInternal(samplesContainer = new Container<PausableSkinnableSound> { RelativeSizeAxes = Axes.Both });
|
||||
}
|
||||
|
||||
protected override void LoadAsyncComplete()
|
||||
@ -296,11 +302,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
/// </summary>
|
||||
protected virtual void LoadSamples()
|
||||
{
|
||||
if (Samples != null)
|
||||
{
|
||||
RemoveInternal(Samples);
|
||||
Samples = null;
|
||||
}
|
||||
samplesContainer.Clear();
|
||||
Samples = null;
|
||||
|
||||
var samples = GetSamples().ToArray();
|
||||
|
||||
@ -313,8 +316,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
|
||||
}
|
||||
|
||||
Samples = new PausableSkinnableSound(samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s)));
|
||||
AddInternal(Samples);
|
||||
samplesContainer.Add(Samples = new PausableSkinnableSound(samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s))));
|
||||
}
|
||||
|
||||
private void onSamplesChanged(object sender, NotifyCollectionChangedEventArgs e) => LoadSamples();
|
||||
|
Loading…
Reference in New Issue
Block a user