diff --git a/src/Files.App/Data/Models/AppModel.cs b/src/Files.App/Data/Models/AppModel.cs index d9a5c5d180ab..82f010556568 100644 --- a/src/Files.App/Data/Models/AppModel.cs +++ b/src/Files.App/Data/Models/AppModel.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. See the LICENSE. using Microsoft.UI.Xaml.Controls; +using System.Runtime.InteropServices; using Windows.ApplicationModel.DataTransfer; namespace Files.App.Data.Models @@ -35,11 +36,18 @@ public int TabStripSelectedIndex { SetProperty(ref _TabStripSelectedIndex, value); - if (value >= 0 && value < MainPageViewModel.AppInstances.Count) + try { - var rootFrame = (Frame)MainWindow.Instance.Content; - var mainView = (MainPage)rootFrame.Content; - mainView.ViewModel.SelectedTabItem = MainPageViewModel.AppInstances[value]; + if (value >= 0 && value < MainPageViewModel.AppInstances.Count) + { + var rootFrame = (Frame)MainWindow.Instance.Content; + var mainView = (MainPage)rootFrame.Content; + mainView.ViewModel.SelectedTabItem = MainPageViewModel.AppInstances[value]; + } + } + catch (COMException) + { + } } } diff --git a/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs b/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs index 8c71927ae001..009315e3f747 100644 --- a/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs @@ -8,6 +8,7 @@ using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls.Primitives; using Microsoft.UI.Xaml.Input; +using System.Runtime.InteropServices; using Windows.System; using Windows.UI.Core; using Windows.Win32; @@ -276,12 +277,19 @@ protected virtual async Task CommitRenameAsync(TextBox textBox) protected virtual async void RenameTextBox_LostFocus(object sender, RoutedEventArgs e) { - // This check allows the user to use the text box context menu without ending the rename - if (!(FocusManager.GetFocusedElement(MainWindow.Instance.Content.XamlRoot) is AppBarButton or Popup)) + try { - TextBox textBox = (TextBox)e.OriginalSource; - await CommitRenameAsync(textBox); + // This check allows the user to use the text box context menu without ending the rename + if (!(FocusManager.GetFocusedElement(MainWindow.Instance.Content.XamlRoot) is AppBarButton or Popup)) + { + TextBox textBox = (TextBox)e.OriginalSource; + await CommitRenameAsync(textBox); + } } + catch (COMException) + { + + } } // Methods diff --git a/src/Files.App/Views/Shells/BaseShellPage.cs b/src/Files.App/Views/Shells/BaseShellPage.cs index 8dfc9b514433..42f2bd43ce1e 100644 --- a/src/Files.App/Views/Shells/BaseShellPage.cs +++ b/src/Files.App/Views/Shells/BaseShellPage.cs @@ -9,6 +9,7 @@ using Microsoft.UI.Xaml.Media.Animation; using Microsoft.UI.Xaml.Navigation; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using Windows.Foundation.Metadata; using Windows.System; using Windows.UI.Core; @@ -756,10 +757,17 @@ protected void SelectSidebarItemFromPath(Type incomingSourcePageType = null) protected void SetLoadingIndicatorForTabs(bool isLoading) { - var multitaskingControls = ((MainWindow.Instance.Content as Frame).Content as MainPage).ViewModel.MultitaskingControls; + try + { + var multitaskingControls = ((MainWindow.Instance.Content as Frame).Content as MainPage).ViewModel.MultitaskingControls; - foreach (var x in multitaskingControls) - x.SetLoadingIndicatorStatus(x.Items.FirstOrDefault(x => x.TabItemContent == PaneHolder), isLoading); + foreach (var x in multitaskingControls) + x.SetLoadingIndicatorStatus(x.Items.FirstOrDefault(x => x.TabItemContent == PaneHolder), isLoading); + } + catch (COMException) + { + + } } // WINUI3