Remove CrashReported from Global
MODIFY
WalletWasabi.Gui/CrashReport/ViewModels/CrashReportWindowViewModel.cs
WalletWasabi.Gui/CrashReport/ViewModels/CrashReportWindowViewModel.cs
@@ -13,8 +13,7 @@ namespace WalletWasabi.Gui.CrashReport.ViewModels
{
public CrashReportWindowViewModel()
{
- var global = Locator.Current.GetService<Global>();
- CrashReporter = global.CrashReporter;
+ CrashReporter = Locator.Current.GetService<CrashReporter>();
OpenLogCommand = ReactiveCommand.CreateFromTask(async () => await FileHelpers.OpenFileInTextEditorAsync(Logger.FilePath));
@@ -36,7 +35,7 @@ namespace WalletWasabi.Gui.CrashReport.ViewModels
public string Title => "Wasabi Wallet - Crash Reporting";
public string ReportTitle => "Wasabi has crashed";
public string Details => $"Unfortunately, Wasabi has crashed. For more information, please open the log file. You may report this crash to the support team.{Environment.NewLine}{Environment.NewLine}Please always consider your privacy before sharing any information!{Environment.NewLine}{Environment.NewLine}Exception information:";
- public string Message => CrashReporter?.SerializedException?.Message;
+ public string? Message => CrashReporter?.SerializedException?.Message;
public ReactiveCommand<Unit, Unit> OpenLogCommand { get; }
public ReactiveCommand<Unit, Unit> OkCommand { get; }

MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -83,7 +83,6 @@ namespace WalletWasabi.Gui
{
using (BenchmarkLogger.Measure())
{
- CrashReporter = new CrashReporter();
StoppingCts = new CancellationTokenSource();
DataDir = dataDir;
Config = config;
@@ -128,7 +127,6 @@ namespace WalletWasabi.Gui
private CancellationTokenSource StoppingCts { get; }
private SingleInstanceChecker SingleInstanceChecker { get; }
- public CrashReporter CrashReporter { get; }
public async Task InitializeNoWalletAsync()
{

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -28,6 +28,9 @@ namespace WalletWasabi.Gui
{
private static Global Global;
+ // This is only used to pass CrashReporter to AppMainAsync.
+ private static CrashReporter CrashReporter = new CrashReporter();
+
/// Warning! In Avalonia applications Main must not be async. Otherwise application may not run on OSX.
/// see https://github.com/AvaloniaUI/Avalonia/wiki/Unresolved-platform-support-issues
private static void Main(string[] args)
@@ -38,8 +41,8 @@ namespace WalletWasabi.Gui
try
{
Global = CreateGlobal();
-
Locator.CurrentMutable.RegisterConstant(Global);
+ Locator.CurrentMutable.RegisterConstant(CrashReporter);
Platform.BaseDirectory = Path.Combine(Global.DataDir, "Gui");
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
@@ -47,7 +50,7 @@ namespace WalletWasabi.Gui
runGui = ShouldRunGui(args);
- if (Global.CrashReporter.IsReport)
+ if (CrashReporter.IsReport)
{
StartCrashReporter(args);
}
@@ -61,7 +64,7 @@ namespace WalletWasabi.Gui
{
appException = ex;
Logger.LogCritical(ex);
- Global?.CrashReporter?.SetException(ex);
+ CrashReporter.SetException(ex);
}
TerminateApplicationAsync(appException).GetAwaiter().GetResult();
@@ -91,7 +94,7 @@ namespace WalletWasabi.Gui
args,
new MixerCommand(daemon),
new PasswordFinderCommand(Global.WalletManager),
- new CrashReportCommand(Global.CrashReporter));
+ new CrashReportCommand(CrashReporter));
return executionTask.GetAwaiter().GetResult();
}
@@ -125,7 +128,7 @@ namespace WalletWasabi.Gui
if (criticalException is { })
{
Logger.LogCritical(criticalException);
- Global?.CrashReporter?.SetException(criticalException);
+ CrashReporter.SetException(criticalException);
}
var mainViewModel = MainWindowViewModel.Instance;
@@ -134,10 +137,10 @@ namespace WalletWasabi.Gui
mainViewModel.Dispose();
}
- if (Global?.CrashReporter?.IsInvokeRequired is true)
+ if (CrashReporter.IsInvokeRequired is true)
{
// Trigger the CrashReport process.
- Global.CrashReporter.TryInvokeCrashReport();
+ CrashReporter.TryInvokeCrashReport();
}
if (Global is { } global)

Remove CrashReported from Global