mirror of
https://github.com/ppy/osu.git
synced 2024-11-20 06:42:54 +08:00
8c3955d341
Finishing an operation started via `OngoingOperationTracker.BeginOperation()` was risky in cases where the operation ended at a callback on another thread (which, in the case of multiplayer, is *most* cases). In particular, if any consumer registered a callback that mutates transforms when the operation ends, it would result in crashes after the framework-side safety checks. Rework `OngoingOperationTracker` into an always-present component residing in the drawable hierarchy, and ensure that the `operationInProgress` bindable is always updated on the update thread. This way consumers don't have to add local schedules in multiple places.
55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
// 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.
|
|
|
|
using NUnit.Framework;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Bindables;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Game.Online.Multiplayer;
|
|
using osu.Game.Screens.OnlinePlay;
|
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
|
{
|
|
public abstract class MultiplayerTestScene : RoomTestScene
|
|
{
|
|
[Cached(typeof(StatefulMultiplayerClient))]
|
|
public TestMultiplayerClient Client { get; }
|
|
|
|
[Cached(typeof(IRoomManager))]
|
|
public TestMultiplayerRoomManager RoomManager { get; }
|
|
|
|
[Cached]
|
|
public Bindable<FilterCriteria> Filter { get; }
|
|
|
|
[Cached]
|
|
public OngoingOperationTracker OngoingOperationTracker { get; }
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
private readonly TestMultiplayerRoomContainer content;
|
|
|
|
private readonly bool joinRoom;
|
|
|
|
protected MultiplayerTestScene(bool joinRoom = true)
|
|
{
|
|
this.joinRoom = joinRoom;
|
|
base.Content.Add(content = new TestMultiplayerRoomContainer { RelativeSizeAxes = Axes.Both });
|
|
|
|
Client = content.Client;
|
|
RoomManager = content.RoomManager;
|
|
Filter = content.Filter;
|
|
OngoingOperationTracker = content.OngoingOperationTracker;
|
|
}
|
|
|
|
[SetUp]
|
|
public new void Setup() => Schedule(() =>
|
|
{
|
|
RoomManager.Schedule(() => RoomManager.PartRoom());
|
|
|
|
if (joinRoom)
|
|
RoomManager.Schedule(() => RoomManager.CreateRoom(Room));
|
|
});
|
|
}
|
|
}
|