mirror of https://github.com/ppy/osu
Avoid stack overflow when trying to push a not-yet async loaded background.
This commit is contained in:
parent
c7f8d2450a
commit
16dc74df5b
|
@ -1 +1 @@
|
||||||
Subproject commit 5c0e4edbbcdc26ab56c70676856477cd21e7afdc
|
Subproject commit adb57b048ea874d61fd1822ad3f270ecb67d1e93
|
|
@ -43,13 +43,18 @@ private void load(BaseGame game)
|
||||||
|
|
||||||
public override bool Push(GameMode mode)
|
public override bool Push(GameMode mode)
|
||||||
{
|
{
|
||||||
//don't actually push until we've finished loading.
|
// When trying to push a non-loaded GameMode, load it asynchronously and re-invoke Push
|
||||||
if (!mode.IsLoaded)
|
// once it's done.
|
||||||
|
if (mode.LoadState == LoadState.NotLoaded)
|
||||||
{
|
{
|
||||||
mode.Preload(game, d => Push((BackgroundMode)d));
|
mode.Preload(game, d => Push((BackgroundMode)d));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure the in-progress loading is complete before pushing the GameMode.
|
||||||
|
while (mode.LoadState < LoadState.Loaded)
|
||||||
|
Thread.Sleep(1);
|
||||||
|
|
||||||
base.Push(mode);
|
base.Push(mode);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue