Skip to content

Commit

Permalink
Prevent missing settings from crashing the app
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahStolk committed May 21, 2024
1 parent 6faea6f commit 4befa3a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Changelog

## [unreleased]
## [0.13.4.0] - 2024-05-21

### Fixes

- Fixed corrupt settings crashing the app.

### Miscellaneous

- Updated Silk.NET dependencies from 2.20.0 to 2.21.0.
- Decreased executable file size by trimming more unused IL code.

## [0.13.3.0] - 2024-04-26
Expand Down
2 changes: 1 addition & 1 deletion src/DevilDaggersInfo.Tools/DevilDaggersInfo.Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<AssemblyName>ddinfo-tools</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>SA1633</NoWarn>
<Version>0.13.3.0</Version>
<Version>0.13.4.0</Version>
<ApplicationIcon>Icon.ico</ApplicationIcon>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<SuppressTrimAnalysisWarnings>false</SuppressTrimAnalysisWarnings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ public UserSettingsModel Sanitize()
{
return this with
{
// ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
DevilDaggersInstallationDirectory = DevilDaggersInstallationDirectory ?? string.Empty,
LookSpeed = Math.Clamp(LookSpeed, LookSpeedMin, LookSpeedMax),
FieldOfView = Math.Clamp(FieldOfView, FieldOfViewMin, FieldOfViewMax),
PracticeTemplates = PracticeTemplates

// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
// May be null for outdated settings files. We cannot make this required for deserialization either, since it would invalidate all old settings.
PracticeTemplates = PracticeTemplates == null ? [] : PracticeTemplates
.Select(pt => pt with
{
HandLevel = Enum.IsDefined(pt.HandLevel) ? pt.HandLevel : HandLevel.Level1,
Expand Down

0 comments on commit 4befa3a

Please sign in to comment.