Skip to content

Commit

Permalink
Merge pull request ppy#24246 from bdach/fix-exit-dialog-crash
Browse files Browse the repository at this point in the history
Fix potential crash in confirm exit dialog while attempting to exit game
  • Loading branch information
peppy authored Jul 16, 2023
2 parents e25cd03 + a42992d commit acb51df
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,30 @@ public void TestExitWithOperationInProgress()
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()
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/Dialog/PopupDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void PerformAction<T>() where T : PopupDialogButton
{
// 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)
Expand Down

0 comments on commit acb51df

Please sign in to comment.