From 0093c5e06c385347f7cc4a854305d426ea6ef5f6 Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Thu, 19 Dec 2024 01:49:39 +0100 Subject: [PATCH] Fix: Fixed crash that would occur when starting Files from WSL directories (#16617) --- src/Files.App/Helpers/Application/AppLifecycleHelper.cs | 1 + src/Files.App/ViewModels/MainPageViewModel.cs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs index 10cfdaf9fa15..c3af6e823151 100644 --- a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs +++ b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs @@ -133,6 +133,7 @@ public static void ConfigureSentry() public static IHost ConfigureHost() { var builder = Host.CreateDefaultBuilder() + .UseContentRoot(Package.Current.InstalledLocation.Path) .UseEnvironment(AppLifecycleHelper.AppEnvironment.ToString()) .ConfigureLogging(builder => builder .ClearProviders() diff --git a/src/Files.App/ViewModels/MainPageViewModel.cs b/src/Files.App/ViewModels/MainPageViewModel.cs index 3953ed7ce984..8a2ba9ce232e 100644 --- a/src/Files.App/ViewModels/MainPageViewModel.cs +++ b/src/Files.App/ViewModels/MainPageViewModel.cs @@ -154,9 +154,9 @@ public async Task OnNavigatedToAsync(NavigationEventArgs e) // add last session tabs to closed tabs stack if those tabs are not about to be opened if (!UserSettingsService.AppSettingsService.RestoreTabsOnStartup && !UserSettingsService.GeneralSettingsService.ContinueLastSessionOnStartUp && UserSettingsService.GeneralSettingsService.LastSessionTabList != null) { - var items = new TabBarItemParameter[UserSettingsService.GeneralSettingsService.LastSessionTabList.Count]; - for (int i = 0; i < items.Length; i++) - items[i] = TabBarItemParameter.Deserialize(UserSettingsService.GeneralSettingsService.LastSessionTabList[i]); + var items = UserSettingsService.GeneralSettingsService.LastSessionTabList + .Where(tab => !string.IsNullOrEmpty(tab)) + .Select(tab => TabBarItemParameter.Deserialize(tab)).ToArray(); BaseTabBar.PushRecentTab(items); }