mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 08:52:55 +08:00
Merge pull request #19651 from bdach/mod-select/mod-preset-buggy-sounds
Fix spurious sample playbacks from already-removed mod preset panels
This commit is contained in:
commit
e79052c8a0
@ -134,6 +134,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
public void TestSoftDeleteSupport()
|
||||
{
|
||||
AddStep("set osu! ruleset", () => Ruleset.Value = rulesets.GetRuleset(0));
|
||||
AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>());
|
||||
AddStep("create content", () => Child = new ModPresetColumn
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
@ -153,9 +154,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
foreach (var preset in r.All<ModPreset>())
|
||||
preset.DeletePending = true;
|
||||
}));
|
||||
AddUntilStep("no panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 0);
|
||||
AddUntilStep("no panels visible", () => !this.ChildrenOfType<ModPresetPanel>().Any());
|
||||
|
||||
AddStep("undelete preset", () => Realm.Write(r =>
|
||||
AddStep("select mods from first preset", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime(), new OsuModHardRock() });
|
||||
|
||||
AddStep("undelete presets", () => Realm.Write(r =>
|
||||
{
|
||||
foreach (var preset in r.All<ModPreset>())
|
||||
preset.DeletePending = false;
|
||||
|
@ -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,15 @@ 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()
|
||||
{
|
||||
foreach (var panel in ItemsFlow.OfType<ModPresetPanel>().ToArray())
|
||||
panel.RemoveAndDisposeImmediately();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
Loading…
Reference in New Issue
Block a user