diff --git a/osu.Game/Graphics/Carousel/Carousel.cs b/osu.Game/Graphics/Carousel/Carousel.cs index 8d8289422b..e5319703be 100644 --- a/osu.Game/Graphics/Carousel/Carousel.cs +++ b/osu.Game/Graphics/Carousel/Carousel.cs @@ -265,7 +265,7 @@ namespace osu.Game.Graphics.Carousel // Copy must be performed on update thread for now (see ConfigureAwait above). // Could potentially be optimised in the future if it becomes an issue. - IEnumerable items = new List(Items.Select(m => new CarouselItem(m))); + List items = new List(Items.Select(m => new CarouselItem(m))); await Task.Run(async () => { @@ -275,6 +275,11 @@ namespace osu.Game.Graphics.Carousel { log($"Performing {filter.GetType().ReadableName()}"); items = await filter.Run(items, cts.Token).ConfigureAwait(false); + + // To avoid shooting ourselves in the foot, ensure that we manifest a list after each filter. + // + // A future improvement may be passing a reference list through each filter rather than copying each time, + // but this is the safest approach. } log("Updating Y positions"); @@ -292,7 +297,7 @@ namespace osu.Game.Graphics.Carousel Schedule(() => { log("Items ready for display"); - carouselItems = items.ToList(); + carouselItems = items; displayedRange = null; // Need to call this to ensure correct post-selection logic is handled on the new items list. diff --git a/osu.Game/Graphics/Carousel/ICarouselFilter.cs b/osu.Game/Graphics/Carousel/ICarouselFilter.cs index 570f480aab..a85b44b46a 100644 --- a/osu.Game/Graphics/Carousel/ICarouselFilter.cs +++ b/osu.Game/Graphics/Carousel/ICarouselFilter.cs @@ -18,6 +18,6 @@ namespace osu.Game.Graphics.Carousel /// The items to be filtered. /// A cancellation token. /// The post-filtered items. - Task> Run(IEnumerable items, CancellationToken cancellationToken); + Task> Run(IEnumerable items, CancellationToken cancellationToken); } } diff --git a/osu.Game/Screens/SelectV2/BeatmapCarouselFilterGrouping.cs b/osu.Game/Screens/SelectV2/BeatmapCarouselFilterGrouping.cs index a628595477..6fbaa19045 100644 --- a/osu.Game/Screens/SelectV2/BeatmapCarouselFilterGrouping.cs +++ b/osu.Game/Screens/SelectV2/BeatmapCarouselFilterGrouping.cs @@ -36,7 +36,7 @@ namespace osu.Game.Screens.SelectV2 this.getCriteria = getCriteria; } - public async Task> Run(IEnumerable items, CancellationToken cancellationToken) + public async Task> Run(IEnumerable items, CancellationToken cancellationToken) { return await Task.Run(() => { diff --git a/osu.Game/Screens/SelectV2/BeatmapCarouselFilterSorting.cs b/osu.Game/Screens/SelectV2/BeatmapCarouselFilterSorting.cs index 22a67321db..2a4f534a47 100644 --- a/osu.Game/Screens/SelectV2/BeatmapCarouselFilterSorting.cs +++ b/osu.Game/Screens/SelectV2/BeatmapCarouselFilterSorting.cs @@ -23,7 +23,7 @@ namespace osu.Game.Screens.SelectV2 this.getCriteria = getCriteria; } - public async Task> Run(IEnumerable items, CancellationToken cancellationToken) => await Task.Run(() => + public async Task> Run(IEnumerable items, CancellationToken cancellationToken) => await Task.Run(() => { var criteria = getCriteria(); @@ -55,7 +55,7 @@ namespace osu.Game.Screens.SelectV2 } return comparison; - })); + })).ToList(); }, cancellationToken).ConfigureAwait(false); } }