Fix crash on restart after update.

Also make update process more graceful.
This commit is contained in:
Dean Herbert 2017-04-11 18:40:39 +09:00
parent 9732110bd9
commit 7d7bea7198
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
2 changed files with 19 additions and 2 deletions

View File

@ -189,19 +189,24 @@ protected override void PopOut()
private class UpdateProgressNotification : ProgressNotification
{
private OsuGame game;
protected override Notification CreateCompletionNotification() => new ProgressCompletionNotification()
{
Text = @"Update ready to install. Click to restart!",
Activated = () =>
{
UpdateManager.RestartApp();
UpdateManager.RestartAppWhenExited();
game.GracefullyExit();
return true;
}
};
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OsuColour colours, OsuGame game)
{
this.game = game;
IconContent.Add(new Drawable[]
{
new Box

View File

@ -307,6 +307,18 @@ protected override bool OnExiting()
return base.OnExiting();
}
/// <summary>
/// Use to programatically exit the game as if the user was triggering via alt-f4.
/// Will keep persisting until an exit occurs (exit may be blocked multiple times).
/// </summary>
public void GracefullyExit()
{
if (!OnExiting())
Exit();
else
Scheduler.AddDelayed(GracefullyExit, 2000);
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();