1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Avoid scheduling during non-current screen

This commit is contained in:
Dean Herbert 2018-03-14 12:01:15 +09:00
parent ef8d595914
commit ea649f9650

View File

@ -131,16 +131,22 @@ namespace osu.Game.Screens.Play
private void pushWhenLoaded()
{
Schedule(pushWhenLoaded);
if (!IsCurrentScreen) return;
if (!readyForPush)
try
{
pushDebounce?.Cancel();
pushDebounce = null;
return;
}
if (!readyForPush)
{
// as the pushDebounce below has a delay, we need to keep checking and cancel a future debounce
// if we become unready for push during the delay.
pushDebounce?.Cancel();
pushDebounce = null;
return;
}
if (pushDebounce != null)
return;
if (pushDebounce == null)
pushDebounce = Scheduler.AddDelayed(() =>
{
contentOut();
@ -159,6 +165,11 @@ namespace osu.Game.Screens.Play
}
});
}, 500);
}
finally
{
Schedule(pushWhenLoaded);
}
}
protected override bool OnExiting(Screen next)