1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 15:27:26 +08:00

Merge pull request #17199 from smoogipoo/fix-multiplayer-test-failures

Fix potential multiplayer crash with async disposal
This commit is contained in:
Dean Herbert 2022-03-10 23:07:05 +09:00 committed by GitHub
commit cee6a12d0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Logging;
using osu.Framework.Screens;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
@ -171,11 +172,25 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
private void onMatchStarted() => Scheduler.Add(() =>
{
if (!this.IsCurrentScreen())
return;
loadingDisplay.Hide();
base.StartGameplay();
});
private void onResultsReady() => resultsReady.SetResult(true);
private void onResultsReady()
{
// Schedule is required to ensure that `TaskCompletionSource.SetResult` is not called more than once.
// A scenario where this can occur is if this instance is not immediately disposed (ie. async disposal queue).
Schedule(() =>
{
if (!this.IsCurrentScreen())
return;
resultsReady.SetResult(true);
});
}
protected override async Task PrepareScoreForResultsAsync(Score score)
{