1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 03:25:11 +08:00

Ensure account creation overlay is shown after logout

Scheduling the entire API state change callback caused the scheduled
hide to fire the first time the user attempted to display the account
creation overlay after a logout, because the drawable wasn't present
before that (so its scheduler wasn't running).

It is not theoretically safe to run `Hide()` unscheduled at its present
call site (as the value change callbacks are fired on the background
API thread). This could also be fixed by setting `AlwaysPresent = true`,
but that's a pretty ugly and unperformant change to make in general.
This commit is contained in:
Bartłomiej Dach 2020-12-25 15:37:14 +01:00
parent 3a6a3a067b
commit 0d8fb83d0a

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Screens;
using osu.Framework.Threading;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API;
@ -93,6 +94,11 @@ namespace osu.Game.Overlays
if (welcomeScreen.GetChildScreen() != null)
welcomeScreen.MakeCurrent();
// there might be a stale scheduled hide from a previous API state change.
// cancel it here so that the overlay is not hidden again after one frame.
scheduledHide?.Cancel();
scheduledHide = null;
}
protected override void PopOut()
@ -101,7 +107,9 @@ namespace osu.Game.Overlays
this.FadeOut(100);
}
private void apiStateChanged(ValueChangedEvent<APIState> state) => Schedule(() =>
private ScheduledDelegate scheduledHide;
private void apiStateChanged(ValueChangedEvent<APIState> state)
{
switch (state.NewValue)
{
@ -113,9 +121,10 @@ namespace osu.Game.Overlays
break;
case APIState.Online:
Hide();
scheduledHide?.Cancel();
scheduledHide = Schedule(Hide);
break;
}
});
}
}
}