mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 15:17:27 +08:00
Merge pull request #24854 from frenzibyte/fix-player-test-scene-crash
Fix crash when loading player instance without exiting previous instance
This commit is contained in:
commit
33582b7273
@ -67,6 +67,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private Player loadPlayerFor(RulesetInfo rulesetInfo)
|
private Player loadPlayerFor(RulesetInfo rulesetInfo)
|
||||||
{
|
{
|
||||||
|
// if a player screen is present already, we must exit that before loading another one,
|
||||||
|
// otherwise it'll crash on SpectatorClient.BeginPlaying being called while client is in "playing" state already.
|
||||||
|
if (Stack.CurrentScreen is Player)
|
||||||
|
Stack.Exit();
|
||||||
|
|
||||||
Ruleset.Value = rulesetInfo;
|
Ruleset.Value = rulesetInfo;
|
||||||
var ruleset = rulesetInfo.CreateInstance();
|
var ruleset = rulesetInfo.CreateInstance();
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ using osu.Framework.Testing;
|
|||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
@ -79,6 +80,11 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected void LoadPlayer(Mod[] mods)
|
protected void LoadPlayer(Mod[] mods)
|
||||||
{
|
{
|
||||||
|
// if a player screen is present already, we must exit that before loading another one,
|
||||||
|
// otherwise it'll crash on SpectatorClient.BeginPlaying being called while client is in "playing" state already.
|
||||||
|
if (Stack.CurrentScreen is Player)
|
||||||
|
Stack.Exit();
|
||||||
|
|
||||||
var ruleset = CreatePlayerRuleset();
|
var ruleset = CreatePlayerRuleset();
|
||||||
Ruleset.Value = ruleset.RulesetInfo;
|
Ruleset.Value = ruleset.RulesetInfo;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user