1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-04 06:12:57 +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 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 } BeatmapInfo = { OnlineBeatmapID = hasOnlineId ? 1234 : (int?)null }
}); });

View File

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

View File

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