1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Fix missing disposal of realm subscriptions in BeatmapCarousel

This commit is contained in:
Dean Herbert 2021-12-17 19:01:19 +09:00
parent 8c4836e87d
commit c9257e9ecc

View File

@ -144,9 +144,13 @@ namespace osu.Game.Screens.Select
private CarouselRoot root;
private IDisposable subscriptionSets;
private IDisposable subscriptionBeatmaps;
private readonly DrawablePool<DrawableCarouselBeatmapSet> setPool = new DrawablePool<DrawableCarouselBeatmapSet>(100);
public BeatmapCarousel()
{
root = new CarouselRoot(this);
InternalChild = new OsuContextMenuContainer
@ -163,10 +167,7 @@ namespace osu.Game.Screens.Select
};
}
[Resolved]
private BeatmapManager beatmaps { get; set; }
[BackgroundDependencyLoader(permitNulls: true)]
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.RandomSelectAlgorithm, RandomAlgorithm);
@ -183,13 +184,10 @@ namespace osu.Game.Screens.Select
{
base.LoadComplete();
realmFactory.Context.All<BeatmapSetInfo>().Where(s => !s.DeletePending).QueryAsyncWithNotifications(beatmapSetsChanged);
realmFactory.Context.All<BeatmapInfo>().Where(b => !b.Hidden).QueryAsyncWithNotifications(beatmapsChanged);
subscriptionSets = realmFactory.Context.All<BeatmapSetInfo>().Where(s => !s.DeletePending).QueryAsyncWithNotifications(beatmapSetsChanged);
subscriptionBeatmaps = realmFactory.Context.All<BeatmapInfo>().Where(b => !b.Hidden).QueryAsyncWithNotifications(beatmapsChanged);
}
private void beatmapRemoved(BeatmapSetInfo item) => RemoveBeatmapSet(item);
private void beatmapUpdated(BeatmapSetInfo item) => UpdateBeatmapSet(item);
private void beatmapSetsChanged(IRealmCollection<BeatmapSetInfo> sender, ChangeSet changes, Exception error)
{
if (changes == null)
@ -921,11 +919,8 @@ namespace osu.Game.Screens.Select
{
base.Dispose(isDisposing);
if (beatmaps != null)
{
beatmaps.ItemUpdated -= beatmapUpdated;
beatmaps.ItemRemoved -= beatmapRemoved;
}
subscriptionSets?.Dispose();
subscriptionBeatmaps?.Dispose();
}
}
}