1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:42:57 +08:00

Fix deadlock when logging out while at the create match screen

Closes https://github.com/ppy/osu/issues/24275.
This commit is contained in:
Dean Herbert 2023-07-19 19:36:51 +09:00
parent 88ac53557a
commit 18aace177a
3 changed files with 15 additions and 14 deletions

View File

@ -23,6 +23,7 @@ using osu.Framework.Screens;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Input.Bindings;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
@ -76,6 +77,9 @@ namespace osu.Game.Screens.OnlinePlay.Match
[Resolved]
private RulesetStore rulesets { get; set; }
[Resolved]
private IAPIProvider api { get; set; } = null!;
[Resolved(canBeNull: true)]
protected OnlinePlayScreen ParentScreen { get; private set; }
@ -284,6 +288,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
[Resolved(canBeNull: true)]
private IDialogOverlay dialogOverlay { get; set; }
protected virtual bool IsConnected => api.State.Value == APIState.Online;
public override bool OnBackButton()
{
if (Room.RoomID.Value == null)
@ -356,6 +362,9 @@ namespace osu.Game.Screens.OnlinePlay.Match
if (ExitConfirmed)
return true;
if (!IsConnected)
return true;
if (dialogOverlay == null || Room.RoomID.Value != null || Room.Playlist.Count == 0)
return true;

View File

@ -17,7 +17,6 @@ using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics.Cursor;
using osu.Game.Online;
using osu.Game.Online.API;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
@ -50,9 +49,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
[Resolved]
private MultiplayerClient client { get; set; }
[Resolved]
private IAPIProvider api { get; set; }
[Resolved(canBeNull: true)]
private OsuGame game { get; set; }
@ -79,6 +75,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
handleRoomLost();
}
protected override bool IsConnected => base.IsConnected && client.IsConnected.Value;
protected override Drawable CreateMainContent() => new Container
{
RelativeSizeAxes = Axes.Both,
@ -254,13 +252,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
public override bool OnExiting(ScreenExitEvent e)
{
// the room may not be left immediately after a disconnection due to async flow,
// so checking the MultiplayerClient / IAPIAccess statuses is also required.
if (client.Room == null || !client.IsConnected.Value || api.State.Value != APIState.Online)
{
// room has not been created yet or we're offline; exit immediately.
// room has not been created yet or we're offline; exit immediately.
if (client.Room == null || !IsConnected)
return base.OnExiting(e);
}
if (!exitConfirmed && dialogOverlay != null)
{

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Screens;
@ -15,8 +13,8 @@ namespace osu.Game.Screens.OnlinePlay
public virtual string ShortTitle => Title;
[Resolved(CanBeNull = true)]
protected IRoomManager RoomManager { get; private set; }
[Resolved]
protected IRoomManager? RoomManager { get; private set; }
protected OnlinePlaySubScreen()
{