mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 10:42:54 +08:00
Merge pull request #17199 from smoogipoo/fix-multiplayer-test-failures
Fix potential multiplayer crash with async disposal
This commit is contained in:
commit
cee6a12d0b
@ -10,6 +10,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
@ -171,11 +172,25 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
|
|
||||||
private void onMatchStarted() => Scheduler.Add(() =>
|
private void onMatchStarted() => Scheduler.Add(() =>
|
||||||
{
|
{
|
||||||
|
if (!this.IsCurrentScreen())
|
||||||
|
return;
|
||||||
|
|
||||||
loadingDisplay.Hide();
|
loadingDisplay.Hide();
|
||||||
base.StartGameplay();
|
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)
|
protected override async Task PrepareScoreForResultsAsync(Score score)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user