mirror of
https://github.com/ppy/osu
synced 2025-01-04 21:30:08 +00:00
Ensure spectator player is unsubscribed to prevent leak
This commit is contained in:
parent
23d9fa4dfa
commit
716458344f
@ -26,12 +26,6 @@ namespace osu.Game.Screens.Play
|
||||
spectatorStreaming.OnUserBeganPlaying += userBeganPlaying;
|
||||
}
|
||||
|
||||
private void userBeganPlaying(int userId, SpectatorState state)
|
||||
{
|
||||
if (userId == Score.ScoreInfo.UserID)
|
||||
Schedule(this.Exit);
|
||||
}
|
||||
|
||||
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
|
||||
{
|
||||
// if we already have frames, start gameplay at the point in time they exist, should they be too far into the beatmap.
|
||||
@ -42,5 +36,25 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
return new GameplayClockContainer(beatmap, firstFrameTime.Value, true);
|
||||
}
|
||||
|
||||
public override bool OnExiting(IScreen next)
|
||||
{
|
||||
spectatorStreaming.OnUserBeganPlaying -= userBeganPlaying;
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (spectatorStreaming != null)
|
||||
spectatorStreaming.OnUserBeganPlaying -= userBeganPlaying;
|
||||
}
|
||||
|
||||
private void userBeganPlaying(int userId, SpectatorState state)
|
||||
{
|
||||
if (userId == Score.ScoreInfo.UserID)
|
||||
Schedule(this.Exit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user