mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 16:27:26 +08:00
Fix missing disposal of realm subscriptions in BeatmapCarousel
This commit is contained in:
parent
8c4836e87d
commit
c9257e9ecc
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user