Skip to content

Fix: Prevent exception when setting SelectedTabIndex before MainPage is loaded #17388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 1, 2025

Conversation

seer-by-sentry[bot]
Copy link
Contributor

@seer-by-sentry seer-by-sentry bot commented Aug 1, 2025

Resolved / Related Issues

To prevent extra work, all changes to the Files codebase must link to an approved issue marked as Ready to build. Please insert the issue number following the hashtag with the issue number that this Pull Request resolves.

Steps used to test these changes

Stability is a top priority for Files and all changes are required to go through testing before being merged into the repo. Please include a list of steps that you used to test this PR.

  1. The issue was that: AppModel's tab selection logic attempts to cast Frame.Content to MainPage while SplashScreenPage's Grid is still active, causing InvalidCastException.
  2. Added a check to ensure that MainWindow.Instance.Content is a Frame and rootFrame.Content is a MainPage before accessing mainView.ViewModel.
  3. This prevents a NullReferenceException that can occur when SelectedTabIndex is set before the MainPage is fully loaded.
  4. This fix was generated by Seer in Sentry, triggered by Yair. 👁️ Run ID: 502085
  5. Not quite right? Click here to continue debugging with Seer.

Copy link
Member

@hishitetsu hishitetsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that they have made the fix based on old code but LGTM.
I wish they had fixed it like this from the beginning.

@yaira2 yaira2 added the ready to merge Pull requests that are approved and ready to merge label Aug 1, 2025
@yaira2 yaira2 marked this pull request as ready for review August 1, 2025 02:32
@yaira2 yaira2 requested a review from hishitetsu August 1, 2025 02:34
@yaira2 yaira2 merged commit c7687ab into main Aug 1, 2025
9 checks passed
@yaira2 yaira2 deleted the seer/fix/selected-tab-index-exception branch August 1, 2025 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Pull requests that are approved and ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants