Skip to content

Commit c64b914

Browse files
Code Quality: Prevent exception when AppModel.LastSelectedTabIndex is set before MainPage is loaded (#17309)
Co-authored-by: seer-by-sentry[bot] <157164994+seer-by-sentry[bot]@users.noreply.github.com>
1 parent 4558bc2 commit c64b914

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Files.App/Data/Models/AppModel.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ public int TabStripSelectedIndex
4343
if (value >= 0 && value < MainPageViewModel.AppInstances.Count)
4444
{
4545
var rootFrame = (Frame)MainWindow.Instance.Content;
46-
var mainView = (MainPage)rootFrame.Content;
47-
mainView.ViewModel.SelectedTabItem = MainPageViewModel.AppInstances[value];
46+
if (rootFrame.Content is MainPage mainView)
47+
{
48+
mainView.ViewModel.SelectedTabItem = MainPageViewModel.AppInstances[value];
49+
}
4850
}
4951
}
5052
catch (COMException)

0 commit comments

Comments
 (0)