Skip to content

Conversation

@workbysaran
Copy link
Contributor

@workbysaran workbysaran commented Sep 15, 2025

Resolved / Related Issues

Closes #17539
Fixed the crash by ensuring the WidgetItems is accessed only on the UI thread.

Steps used to test these changes

  1. Open the Files app
  2. Add a new tab
  3. Immediately click on a pinned item in the left panel before the tab completes loading
  4. Verify that no exception is thrown and the folder opens correctly
  5. Verify that normal tab navigation and pinned item access work as expected

Copy link
Member

@0x5bfa 0x5bfa left a comment

Choose a reason for hiding this comment

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

Otherwise, LGTM.


public void RefreshWidgetList()
{
for (int i = 0; i < WidgetItems.Count; i++)
Copy link
Member

Choose a reason for hiding this comment

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

Why is this reversed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Backward iteration avoids skipped items from index shifts and works safely with DispatcherQueue UI updates.

@yaira2 yaira2 added the ready for review Pull requests that are ready for review label Sep 15, 2025
@yaira2 yaira2 requested a review from Copilot September 15, 2025 14:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a crash that occurs when users click on pinned items in the left panel before a tab completes loading. The fix ensures that WidgetItems collection is accessed only on the UI thread to prevent cross-thread access violations.

Key changes:

  • Wraps all WidgetItems collection operations in UI thread dispatching
  • Fixes iteration direction in RefreshWidgetList to handle collection modifications
  • Improves thread safety for widget management operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@yaira2 yaira2 changed the title Fix: Fixed the crash by ensuring the WidgetItems is accessed only on … Fix: Fixed crash that would occur when opening pinned items Sep 15, 2025
@yaira2 yaira2 changed the title Fix: Fixed crash that would occur when opening pinned items Fix: Fixed crash that sometimes occured when opening pinned items Sep 15, 2025
@yaira2 yaira2 added ready to merge Pull requests that are approved and ready to merge and removed ready for review Pull requests that are ready for review labels Sep 16, 2025
@yaira2 yaira2 merged commit 7e8250b into files-community:main Sep 16, 2025
6 checks passed
@yaira2 yaira2 changed the title Fix: Fixed crash that sometimes occured when opening pinned items Fix: Fixed crash that sometimes occurred when opening pinned items Sep 16, 2025
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.

Bug: Clicking pinned item while tab is loading causes app to crash

3 participants