mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
enhance: secure exit
This commit is contained in:
parent
f4eca45754
commit
3aad24a64e
4 changed files with 15 additions and 11 deletions
|
@ -122,7 +122,7 @@ namespace SourceGit
|
||||||
Check4Update(true);
|
Check4Update(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
public static readonly SimpleCommand QuitCommand = new SimpleCommand(Quit);
|
public static readonly SimpleCommand QuitCommand = new SimpleCommand(() => Quit(0));
|
||||||
|
|
||||||
public static void RaiseException(string context, string message)
|
public static void RaiseException(string context, string message)
|
||||||
{
|
{
|
||||||
|
@ -315,12 +315,16 @@ namespace SourceGit
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Quit()
|
public static void Quit(int exitCode)
|
||||||
{
|
{
|
||||||
if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
desktop.MainWindow?.Close();
|
desktop.MainWindow?.Close();
|
||||||
desktop.Shutdown();
|
desktop.Shutdown(exitCode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Environment.Exit(exitCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,9 +489,10 @@ namespace SourceGit
|
||||||
|
|
||||||
var file = args[1];
|
var file = args[1];
|
||||||
if (!File.Exists(file))
|
if (!File.Exists(file))
|
||||||
Environment.Exit(-1);
|
desktop.Shutdown(-1);
|
||||||
|
else
|
||||||
|
desktop.MainWindow = new Views.StandaloneCommitMessageEditor(file);
|
||||||
|
|
||||||
desktop.MainWindow = new Views.StandaloneCommitMessageEditor(file);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
App.Quit();
|
App.Quit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -50,13 +50,13 @@ namespace SourceGit.Views
|
||||||
private void CloseWindow(object _1, RoutedEventArgs _2)
|
private void CloseWindow(object _1, RoutedEventArgs _2)
|
||||||
{
|
{
|
||||||
Console.Out.WriteLine("No passphrase entered.");
|
Console.Out.WriteLine("No passphrase entered.");
|
||||||
Environment.Exit(-1);
|
App.Quit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnterPassword(object _1, RoutedEventArgs _2)
|
private void EnterPassword(object _1, RoutedEventArgs _2)
|
||||||
{
|
{
|
||||||
Console.Out.Write($"{Passphrase}\n");
|
Console.Out.Write($"{Passphrase}\n");
|
||||||
Environment.Exit(0);
|
App.Quit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
|
@ -41,13 +40,13 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
private void CloseWindow(object _1, RoutedEventArgs _2)
|
private void CloseWindow(object _1, RoutedEventArgs _2)
|
||||||
{
|
{
|
||||||
Environment.Exit(-1);
|
App.Quit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveAndClose(object _1, RoutedEventArgs _2)
|
private void SaveAndClose(object _1, RoutedEventArgs _2)
|
||||||
{
|
{
|
||||||
File.WriteAllText(_file, Editor.Text);
|
File.WriteAllText(_file, Editor.Text);
|
||||||
Environment.Exit(0);
|
App.Quit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly string _file;
|
private readonly string _file;
|
||||||
|
|
Loading…
Reference in a new issue