1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 16:47:29 +08:00

Merge pull request #24246 from bdach/fix-exit-dialog-crash

Fix potential crash in confirm exit dialog while attempting to exit game
This commit is contained in:
Dean Herbert 2023-07-17 01:11:07 +09:00 committed by GitHub
commit acb51dfca3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -722,6 +722,30 @@ namespace osu.Game.Tests.Visual.Navigation
AddUntilStep("Wait for game exit", () => Game.ScreenStack.CurrentScreen == null);
}
[Test]
public void TestForceExitWithOperationInProgress()
{
AddStep("set hold delay to 0", () => Game.LocalConfig.SetValue(OsuSetting.UIHoldActivationDelay, 0.0));
AddUntilStep("wait for dialog overlay", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault() != null);
AddStep("start ongoing operation", () =>
{
Game.Notifications.Post(new ProgressNotification
{
Text = "Something is still running",
Progress = 0.5f,
State = ProgressNotificationState.Active,
});
});
AddStep("attempt exit", () =>
{
for (int i = 0; i < 2; ++i)
Game.ScreenStack.CurrentScreen.Exit();
});
AddUntilStep("stopped at exit confirm", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is ConfirmExitDialog);
}
[Test]
public void TestExitGameFromSongSelect()
{

View File

@ -229,7 +229,7 @@ namespace osu.Game.Overlays.Dialog
{
// Buttons are regularly added in BDL or LoadComplete, so let's schedule to ensure
// they are ready to be pressed.
Schedule(() => Buttons.OfType<T>().First().TriggerClick());
Schedule(() => Buttons.OfType<T>().FirstOrDefault()?.TriggerClick());
}
protected override bool OnKeyDown(KeyDownEvent e)