Skip to content

Commit

Permalink
Lease selected room while in match screen to avoid lounge potentially…
Browse files Browse the repository at this point in the history
… changing it
  • Loading branch information
peppy committed Aug 12, 2021
1 parent 054e0e8 commit 4d6101f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Expand Up @@ -137,7 +137,9 @@ private void removeRooms(IEnumerable<Room> rooms)

roomFlow.Remove(toRemove);

selectedRoom.Value = null;
// selection may have a lease due to being in a sub screen.
if (!selectedRoom.Disabled)
selectedRoom.Value = null;
}
}

Expand Down
13 changes: 12 additions & 1 deletion osu.Game/Screens/OnlinePlay/Lounge/LoungeSubScreen.cs
Expand Up @@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
Expand Down Expand Up @@ -49,6 +50,9 @@ public abstract class LoungeSubScreen : OnlinePlaySubScreen

private RoomsContainer roomsContainer;

[CanBeNull]
private LeasedBindable<Room> selectionLease;

[BackgroundDependencyLoader]
private void load()
{
Expand Down Expand Up @@ -144,6 +148,11 @@ public override void OnResuming(IScreen last)
{
base.OnResuming(last);

Debug.Assert(selectionLease != null);

selectionLease.Return();
selectionLease = null;

if (selectedRoom.Value?.RoomID.Value == null)
selectedRoom.Value = new Room();

Expand Down Expand Up @@ -210,7 +219,9 @@ private void onLeaving()

protected virtual void OpenNewRoom(Room room)
{
selectedRoom.Value = room;
selectionLease = selectedRoom.BeginLease(false);
Debug.Assert(selectionLease != null);
selectionLease.Value = room;

this.Push(CreateRoomSubScreen(room));
}
Expand Down

0 comments on commit 4d6101f

Please sign in to comment.