mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
UI - Fix error message on Windows shutdown on some systems
This commit is contained in:
parent
169f8c514e
commit
1e3121a4df
@ -27,6 +27,7 @@ namespace Artemis.UI
|
|||||||
{
|
{
|
||||||
private ApplicationStateManager _applicationStateManager;
|
private ApplicationStateManager _applicationStateManager;
|
||||||
private ICoreService _core;
|
private ICoreService _core;
|
||||||
|
private ILogger _exceptionLogger;
|
||||||
|
|
||||||
public Bootstrapper()
|
public Bootstrapper()
|
||||||
{
|
{
|
||||||
@ -49,10 +50,10 @@ namespace Artemis.UI
|
|||||||
_applicationStateManager = new ApplicationStateManager(Kernel, Args);
|
_applicationStateManager = new ApplicationStateManager(Kernel, Args);
|
||||||
Core.Utilities.PrepareFirstLaunch();
|
Core.Utilities.PrepareFirstLaunch();
|
||||||
|
|
||||||
ILogger logger = Kernel.Get<ILogger>();
|
_exceptionLogger = Kernel.Get<ILogger>();
|
||||||
if (_applicationStateManager.FocusExistingInstance())
|
if (_applicationStateManager.FocusExistingInstance())
|
||||||
{
|
{
|
||||||
logger.Information("Shutting down because a different instance is already running.");
|
_exceptionLogger.Information("Shutting down because a different instance is already running.");
|
||||||
Application.Current.Shutdown(1);
|
Application.Current.Shutdown(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -63,7 +64,7 @@ namespace Artemis.UI
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.Error($"Failed to set DPI-Awareness: {ex.Message}");
|
_exceptionLogger.Error($"Failed to set DPI-Awareness: {ex.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
IViewManager viewManager = Kernel.Get<IViewManager>();
|
IViewManager viewManager = Kernel.Get<IViewManager>();
|
||||||
@ -76,7 +77,7 @@ namespace Artemis.UI
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
HandleFatalException(e, logger);
|
HandleFatalException(e);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +102,7 @@ namespace Artemis.UI
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
HandleFatalException(e, logger);
|
HandleFatalException(e);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -132,12 +133,11 @@ namespace Artemis.UI
|
|||||||
|
|
||||||
protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e)
|
protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
ILogger logger = Kernel.Get<ILogger>();
|
|
||||||
logger.Fatal(e.Exception, "Unhandled exception");
|
|
||||||
|
|
||||||
IDialogService dialogService = Kernel.Get<IDialogService>();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
_exceptionLogger.Fatal(e.Exception, "Unhandled exception");
|
||||||
|
|
||||||
|
IDialogService dialogService = Kernel.Get<IDialogService>();
|
||||||
dialogService.ShowExceptionDialog("Artemis encountered an error", e.Exception);
|
dialogService.ShowExceptionDialog("Artemis encountered an error", e.Exception);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@ -149,9 +149,9 @@ namespace Artemis.UI
|
|||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleFatalException(Exception e, ILogger logger)
|
private void HandleFatalException(Exception e)
|
||||||
{
|
{
|
||||||
logger.Fatal(e, "Fatal exception during initialization, shutting down.");
|
_exceptionLogger.Fatal(e, "Fatal exception during initialization, shutting down.");
|
||||||
Execute.OnUIThread(() =>
|
Execute.OnUIThread(() =>
|
||||||
{
|
{
|
||||||
_applicationStateManager.DisplayException(e);
|
_applicationStateManager.DisplayException(e);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user