Fix exception when adding duplicate items

This commit is contained in:
smoogipoo 2020-02-14 19:56:01 +09:00
parent f0f739707f
commit f31220c1ee
2 changed files with 10 additions and 0 deletions

View File

@ -126,6 +126,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("playlist has 1 item", () => Room.Playlist.Count == 1);
}
[Test]
public void TestAddSameItemMultipleTimes()
{
AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem());
AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem());
AddAssert("playlist has 2 items", () => Room.Playlist.Count == 2);
}
private class TestMatchSongSelect : MatchSongSelect
{
public new MatchBeatmapDetailArea BeatmapDetails => (MatchBeatmapDetailArea)base.BeatmapDetails;

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using Humanizer;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -53,6 +54,7 @@ namespace osu.Game.Screens.Select
{
PlaylistItem item = new PlaylistItem
{
ID = (Playlist.LastOrDefault()?.ID + 1) ?? 0,
Beatmap = { Value = Beatmap.Value.BeatmapInfo },
Ruleset = { Value = Ruleset.Value }
};