Fix race due to StopWatchingUser() being called asynchronously

This commit is contained in:
smoogipoo 2021-05-20 19:45:11 +09:00
parent 5a8b8782d3
commit 06c99e8c7c

View File

@ -181,10 +181,14 @@ namespace osu.Game.Online.Spectator
} }
public void StopWatchingUser(int userId) public void StopWatchingUser(int userId)
{
// This method is most commonly called via Dispose(), which is asynchronous.
// Todo: This should not be a thing, but requires framework changes.
Schedule(() =>
{ {
watchingUsers.Remove(userId); watchingUsers.Remove(userId);
StopWatchingUserInternal(userId); StopWatchingUserInternal(userId);
});
} }
protected abstract Task BeginPlayingInternal(SpectatorState state); protected abstract Task BeginPlayingInternal(SpectatorState state);