Fix crash when quickly exiting multiplayer after joining a room (#6666)

Fix crash when quickly exiting multiplayer after joining a room
This commit is contained in:
Dean Herbert 2019-10-31 13:15:46 +09:00 committed by GitHub
commit 5b5703544b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -212,6 +212,8 @@ public override void OnSuspending(IScreen next)
public override bool OnExiting(IScreen next)
{
roomManager.PartRoom();
if (screenStack.CurrentScreen != null && !(screenStack.CurrentScreen is LoungeSubScreen))
{
screenStack.Exit();

View File

@ -87,9 +87,8 @@ public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string>
public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
{
currentJoinRoomRequest?.Cancel();
currentJoinRoomRequest = null;
currentJoinRoomRequest = new JoinRoomRequest(room, api.LocalUser.Value);
currentJoinRoomRequest.Success += () =>
{
joinedRoom = room;
@ -98,7 +97,8 @@ public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> on
currentJoinRoomRequest.Failure += exception =>
{
Logger.Log($"Failed to join room: {exception}", level: LogLevel.Important);
if (!(exception is OperationCanceledException))
Logger.Log($"Failed to join room: {exception}", level: LogLevel.Important);
onError?.Invoke(exception.ToString());
};
@ -107,6 +107,8 @@ public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> on
public void PartRoom()
{
currentJoinRoomRequest?.Cancel();
if (joinedRoom == null)
return;