1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 10:07:36 +08:00

Avoid stack overflow when trying to push a not-yet async loaded background.

This commit is contained in:
Thomas Müller 2016-11-12 18:33:47 +01:00
parent c7f8d2450a
commit 16dc74df5b
2 changed files with 8 additions and 3 deletions

@ -1 +1 @@
Subproject commit 5c0e4edbbcdc26ab56c70676856477cd21e7afdc
Subproject commit adb57b048ea874d61fd1822ad3f270ecb67d1e93

View File

@ -43,13 +43,18 @@ namespace osu.Game.GameModes
public override bool Push(GameMode mode)
{
//don't actually push until we've finished loading.
if (!mode.IsLoaded)
// When trying to push a non-loaded GameMode, load it asynchronously and re-invoke Push
// once it's done.
if (mode.LoadState == LoadState.NotLoaded)
{
mode.Preload(game, d => Push((BackgroundMode)d));
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);
return true;