Skip to content

Commit 0812db0

Browse files
committed
Fix: Fixed crash that would occur when using an invalid background image
1 parent b14b559 commit 0812db0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Files.App/ViewModels/MainPageViewModel.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ public float AppThemeBackgroundImageOpacity
8989
=> AppearanceSettingsService.AppThemeBackgroundImageOpacity;
9090

9191
public ImageSource? AppThemeBackgroundImageSource =>
92-
string.IsNullOrEmpty(AppearanceSettingsService.AppThemeBackgroundImageSource)
93-
? null
94-
: new BitmapImage(new Uri(AppearanceSettingsService.AppThemeBackgroundImageSource, UriKind.RelativeOrAbsolute));
92+
!string.IsNullOrEmpty(AppearanceSettingsService.AppThemeBackgroundImageSource) &&
93+
Uri.TryCreate(AppearanceSettingsService.AppThemeBackgroundImageSource, UriKind.RelativeOrAbsolute, out Uri? validUri)
94+
? new BitmapImage(validUri)
95+
: null;
9596

9697
public VerticalAlignment AppThemeBackgroundImageVerticalAlignment
9798
=> AppearanceSettingsService.AppThemeBackgroundImageVerticalAlignment;

0 commit comments

Comments
 (0)