1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-03 17:12:55 +08:00

Fix possibly setting null track

This commit is contained in:
smoogipoo 2020-08-07 22:05:58 +09:00
parent 08820c62ec
commit b6fb7a0d39
3 changed files with 6 additions and 7 deletions

View File

@ -59,7 +59,7 @@ namespace osu.Game.Tests.Visual.Online
{
AddStep("Set activity", () => API.Activity.Value = new UserActivity.InLobby());
AddStep("Set beatmap", () => Beatmap.Value = new DummyWorkingBeatmap(null, null)
AddStep("Set beatmap", () => Beatmap.Value = new DummyWorkingBeatmap(Audio, null)
{
BeatmapInfo = { OnlineBeatmapID = hasOnlineId ? 1234 : (int?)null }
});

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using JetBrains.Annotations;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Extensions.IEnumerableExtensions;
@ -19,7 +20,7 @@ namespace osu.Game.Beatmaps
{
private readonly TextureStore textures;
public DummyWorkingBeatmap(AudioManager audio, TextureStore textures)
public DummyWorkingBeatmap([NotNull] AudioManager audio, TextureStore textures)
: base(new BeatmapInfo
{
Metadata = new BeatmapMetadata

View File

@ -321,15 +321,13 @@ namespace osu.Game.Overlays
private void changeTrack()
{
CurrentTrack.Expire();
CurrentTrack = null;
CurrentTrack = new DrawableTrack(new TrackVirtual(1000));
if (current != null)
{
CurrentTrack = new DrawableTrack(current.GetRealTrack());
CurrentTrack.Completed += () => onTrackCompleted(current);
AddInternal(CurrentTrack);
}
CurrentTrack.Completed += () => onTrackCompleted(current);
AddInternal(CurrentTrack);
}
private void onTrackCompleted(WorkingBeatmap workingBeatmap)