-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix: Fixed crash that sometimes occurred when opening pinned items #17611
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
Fix: Fixed crash that sometimes occurred when opening pinned items #17611
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, LGTM.
@@ -105,7 +105,7 @@ private void ReloadWidgets() | |||
|
|||
public void RefreshWidgetList() | |||
{ | |||
for (int i = 0; i < WidgetItems.Count; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this reversed?
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
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