diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index 02acc359b9..397bddbdd0 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -375,8 +375,7 @@ namespace osu.Game.Rulesets.UI /// The receiver for s. public void RegisterPool(int initialSize, int? maximumSize = null) where TObject : HitObject - where TDrawable : DrawableHitObject, new() - => RegisterPool(new DrawablePool(initialSize, maximumSize)); + where TDrawable : DrawableHitObject, new() => RegisterPool(new DrawablePool(initialSize, maximumSize)); /// /// Registers a custom pool with this which is to be used whenever @@ -497,6 +496,18 @@ namespace osu.Game.Rulesets.UI protected override PoolableSkinnableSample CreateNewDrawable() => base.CreateNewDrawable().With(d => d.Apply(sampleInfo)); } + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + if (isDisposing) + { + // 只清空字典引用 + // pool 会随着 Playfield 的 disposal 被自动处理。 + samplePools.Clear(); + } + } + #endregion private void onNewResult(DrawableHitObject drawable, JudgementResult result)