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() private void pushWhenLoaded()
{ {
Schedule(pushWhenLoaded); if (!IsCurrentScreen) return;
if (!readyForPush) try
{ {
pushDebounce?.Cancel(); if (!readyForPush)
pushDebounce = null; {
return; // 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(() => pushDebounce = Scheduler.AddDelayed(() =>
{ {
contentOut(); contentOut();
@ -159,6 +165,11 @@ namespace osu.Game.Screens.Play
} }
}); });
}, 500); }, 500);
}
finally
{
Schedule(pushWhenLoaded);
}
} }
protected override bool OnExiting(Screen next) protected override bool OnExiting(Screen next)