Browse Source

Don't crash if close window when picking data dir

pull/14/head
JT 1 year ago
parent
commit
db042bbd5b
  1. 7
      StabilityMatrix/App.xaml.cs
  2. 6
      StabilityMatrix/MainWindow.xaml.cs

7
StabilityMatrix/App.xaml.cs

@ -345,7 +345,12 @@ namespace StabilityMatrix
private void App_OnExit(object sender, ExitEventArgs e)
{
serviceProvider?.GetRequiredService<LaunchViewModel>().OnShutdown();
serviceProvider?.GetRequiredService<ILiteDbContext>().Dispose();
var settingsManager = serviceProvider?.GetRequiredService<ISettingsManager>();
if (settingsManager?.TryFindLibrary() ?? false)
{
serviceProvider?.GetRequiredService<ILiteDbContext>().Dispose();
}
}
[DoesNotReturn]

6
StabilityMatrix/MainWindow.xaml.cs

@ -127,7 +127,11 @@ namespace StabilityMatrix
{
var interopHelper = new WindowInteropHelper(this);
var placement = ScreenExtensions.GetPlacement(interopHelper.Handle);
settingsManager.SetPlacement(placement.ToString());
if (settingsManager.TryFindLibrary())
{
settingsManager.SetPlacement(placement.ToString());
}
}
}
}

Loading…
Cancel
Save