1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 02:32:55 +08:00

Ignore possible nulls in NotifyCollectionChangedArgs

Safe to access by the virtue of the preceding case labels on
`args.Action`.  And they're in test code anyways.
This commit is contained in:
Bartłomiej Dach 2021-05-14 23:52:16 +02:00
parent e62e473bb2
commit d581e0a252

View File

@ -13,6 +13,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
@ -45,14 +46,14 @@ namespace osu.Game.Tests.Visual.Online
switch (args.Action) switch (args.Action)
{ {
case NotifyCollectionChangedAction.Add: case NotifyCollectionChangedAction.Add:
args.NewItems.Cast<Mod>().ForEach(mod => selectedMods.Add(new OsuSpriteText args.NewItems.AsNonNull().Cast<Mod>().ForEach(mod => selectedMods.Add(new OsuSpriteText
{ {
Text = mod.Acronym, Text = mod.Acronym,
})); }));
break; break;
case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Remove:
args.OldItems.Cast<Mod>().ForEach(mod => args.OldItems.AsNonNull().Cast<Mod>().ForEach(mod =>
{ {
foreach (var selected in selectedMods) foreach (var selected in selectedMods)
{ {