1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 02:52:54 +08:00

Fix null reference in change handling code

This commit is contained in:
Dean Herbert 2024-08-28 16:19:17 +09:00
parent 081c9eb21b
commit 81b36d897d
No known key found for this signature in database

View File

@ -274,30 +274,31 @@ namespace osu.Game.Screens.Select
if (loadedTestBeatmaps)
return;
var newBeatmapSets = changed.NewItems!.Cast<BeatmapSetInfo>();
var newBeatmapSetIDs = newBeatmapSets.Select(s => s.ID).ToHashSet();
var oldBeatmapSets = changed.OldItems!.Cast<BeatmapSetInfo>();
var oldBeatmapSetIDs = oldBeatmapSets.Select(s => s.ID).ToHashSet();
IEnumerable<BeatmapSetInfo>? newBeatmapSets = changed.NewItems?.Cast<BeatmapSetInfo>();
switch (changed.Action)
{
case NotifyCollectionChangedAction.Add:
HashSet<Guid> newBeatmapSetIDs = newBeatmapSets!.Select(s => s.ID).ToHashSet();
setsRequiringRemoval.RemoveWhere(s => newBeatmapSetIDs.Contains(s.ID));
setsRequiringUpdate.AddRange(newBeatmapSets);
setsRequiringUpdate.AddRange(newBeatmapSets!);
break;
case NotifyCollectionChangedAction.Remove:
IEnumerable<BeatmapSetInfo> oldBeatmapSets = changed.OldItems!.Cast<BeatmapSetInfo>();
HashSet<Guid> oldBeatmapSetIDs = oldBeatmapSets.Select(s => s.ID).ToHashSet();
setsRequiringUpdate.RemoveWhere(s => oldBeatmapSetIDs.Contains(s.ID));
setsRequiringRemoval.AddRange(oldBeatmapSets);
break;
case NotifyCollectionChangedAction.Replace:
setsRequiringUpdate.AddRange(newBeatmapSets);
setsRequiringUpdate.AddRange(newBeatmapSets!);
break;
case NotifyCollectionChangedAction.Move:
setsRequiringUpdate.AddRange(newBeatmapSets);
setsRequiringUpdate.AddRange(newBeatmapSets!);
break;
case NotifyCollectionChangedAction.Reset: