1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 08:22:56 +08:00

Fix GameplayClockContainer operating on beatmap's track after s… (#6688)

Fix GameplayClockContainer operating on beatmap's track after screen exited
This commit is contained in:
Dean Herbert 2019-11-02 21:22:13 +09:00 committed by GitHub
commit 551032803d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -8,6 +8,7 @@ using System.Threading.Tasks;
using osu.Framework; using osu.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -29,7 +30,7 @@ namespace osu.Game.Screens.Play
/// <summary> /// <summary>
/// The original source (usually a <see cref="WorkingBeatmap"/>'s track). /// The original source (usually a <see cref="WorkingBeatmap"/>'s track).
/// </summary> /// </summary>
private readonly IAdjustableClock sourceClock; private IAdjustableClock sourceClock;
public readonly BindableBool IsPaused = new BindableBool(); public readonly BindableBool IsPaused = new BindableBool();
@ -153,6 +154,18 @@ namespace osu.Game.Screens.Play
IsPaused.Value = true; IsPaused.Value = true;
} }
/// <summary>
/// Changes the backing clock to avoid using the originally provided beatmap's track.
/// </summary>
public void StopUsingBeatmapClock()
{
if (sourceClock != beatmap.Track)
return;
sourceClock = new TrackVirtual(beatmap.Track.Length);
adjustableClock.ChangeSource(sourceClock);
}
public void ResetLocalAdjustments() public void ResetLocalAdjustments()
{ {
// In the case of replays, we may have changed the playback rate. // In the case of replays, we may have changed the playback rate.

View File

@ -532,6 +532,10 @@ namespace osu.Game.Screens.Play
GameplayClockContainer.ResetLocalAdjustments(); GameplayClockContainer.ResetLocalAdjustments();
// GameplayClockContainer performs seeks / start / stop operations on the beatmap's track.
// as we are no longer the current screen, we cannot guarantee the track is still usable.
GameplayClockContainer.StopUsingBeatmapClock();
fadeOut(); fadeOut();
return base.OnExiting(next); return base.OnExiting(next);
} }