mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 07:43:01 +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)
|
if (loadedTestBeatmaps)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var newBeatmapSets = changed.NewItems!.Cast<BeatmapSetInfo>();
|
IEnumerable<BeatmapSetInfo>? 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();
|
|
||||||
|
|
||||||
switch (changed.Action)
|
switch (changed.Action)
|
||||||
{
|
{
|
||||||
case NotifyCollectionChangedAction.Add:
|
case NotifyCollectionChangedAction.Add:
|
||||||
|
HashSet<Guid> newBeatmapSetIDs = newBeatmapSets!.Select(s => s.ID).ToHashSet();
|
||||||
|
|
||||||
setsRequiringRemoval.RemoveWhere(s => newBeatmapSetIDs.Contains(s.ID));
|
setsRequiringRemoval.RemoveWhere(s => newBeatmapSetIDs.Contains(s.ID));
|
||||||
setsRequiringUpdate.AddRange(newBeatmapSets);
|
setsRequiringUpdate.AddRange(newBeatmapSets!);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotifyCollectionChangedAction.Remove:
|
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));
|
setsRequiringUpdate.RemoveWhere(s => oldBeatmapSetIDs.Contains(s.ID));
|
||||||
setsRequiringRemoval.AddRange(oldBeatmapSets);
|
setsRequiringRemoval.AddRange(oldBeatmapSets);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotifyCollectionChangedAction.Replace:
|
case NotifyCollectionChangedAction.Replace:
|
||||||
setsRequiringUpdate.AddRange(newBeatmapSets);
|
setsRequiringUpdate.AddRange(newBeatmapSets!);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotifyCollectionChangedAction.Move:
|
case NotifyCollectionChangedAction.Move:
|
||||||
setsRequiringUpdate.AddRange(newBeatmapSets);
|
setsRequiringUpdate.AddRange(newBeatmapSets!);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotifyCollectionChangedAction.Reset:
|
case NotifyCollectionChangedAction.Reset:
|
||||||
|
Loading…
Reference in New Issue
Block a user