1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 14:12:56 +08:00

Fix spurious sample playbacks from already-removed panels

This commit is contained in:
Bartłomiej Dach 2022-08-08 20:30:21 +02:00
parent eba070a0f8
commit a0a6e1faee
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -7,6 +7,7 @@ using System.Threading;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Localisation;
@ -66,7 +67,7 @@ namespace osu.Game.Overlays.Mods
if (!presets.Any())
{
ItemsFlow.RemoveAll(panel => panel is ModPresetPanel);
removeAndDisposePresetPanels();
return;
}
@ -75,9 +76,23 @@ namespace osu.Game.Overlays.Mods
Shear = Vector2.Zero
}), loaded =>
{
ItemsFlow.RemoveAll(panel => panel is ModPresetPanel);
removeAndDisposePresetPanels();
ItemsFlow.AddRange(loaded);
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
void removeAndDisposePresetPanels()
{
int i = 0;
while (i < ItemsFlow.Count)
{
var item = ItemsFlow[i];
if (item is ModPresetPanel)
item.RemoveAndDisposeImmediately();
else
i++;
}
}
}
protected override void Dispose(bool isDisposing)