mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 21:02:56 +08:00
Fix null reference in change handling code
This commit is contained in:
parent
081c9eb21b
commit
81b36d897d
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user