1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 08:27:49 +08:00

Merge pull request #26541 from peppy/fix-collection-dropdown-crash

Fix collection dropdown crashing when all collections are deleted at once
This commit is contained in:
Bartłomiej Dach 2024-01-15 13:28:00 +01:00 committed by GitHub
commit fe8540b441
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -76,6 +76,20 @@ namespace osu.Game.Tests.Visual.SongSelect
assertCollectionDropdownContains("2");
}
[Test]
public void TestCollectionsCleared()
{
AddStep("add collection", () => writeAndRefresh(r => r.Add(new BeatmapCollection(name: "1"))));
AddStep("add collection", () => writeAndRefresh(r => r.Add(new BeatmapCollection(name: "2"))));
AddStep("add collection", () => writeAndRefresh(r => r.Add(new BeatmapCollection(name: "3"))));
AddAssert("check count 5", () => control.ChildrenOfType<CollectionDropdown>().Single().ChildrenOfType<Menu.DrawableMenuItem>().Count(), () => Is.EqualTo(5));
AddStep("delete all collections", () => writeAndRefresh(r => r.RemoveAll<BeatmapCollection>()));
AddAssert("check count 2", () => control.ChildrenOfType<CollectionDropdown>().Single().ChildrenOfType<Menu.DrawableMenuItem>().Count(), () => Is.EqualTo(2));
}
[Test]
public void TestCollectionRemovedFromDropdown()
{

View File

@ -74,7 +74,7 @@ namespace osu.Game.Collections
}
else
{
foreach (int i in changes.DeletedIndices)
foreach (int i in changes.DeletedIndices.OrderByDescending(i => i))
filters.RemoveAt(i + 1);
foreach (int i in changes.InsertedIndices)