-
Notifications
You must be signed in to change notification settings - Fork 1k
Intermittent exception when creating a ListViewGroupAccessibleObject #10934
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
Intermittent exception when creating a ListViewGroupAccessibleObject #10934
Conversation
babced7
to
af5f665
Compare
…xample when the corresponding control is not displayed or not parented, thus changing nullability on this property. We were already guarding against accessing objects for "invisiable" groups in the parent ListViewAccessibleObject when enumerating children. We should not attempt to create accessible object for unparented ListView groups, for example when a group is removed from the control. This fix is based on this call stack: System.InvalidOperationException: ListView at System.Windows.Forms.ListViewGroup.ListViewGroupAccessibleObject..ctor(ListViewGroup owningGroup, Boolean owningGroupIsDefault) at System.Windows.Forms.ListViewGroup.get_AccessibilityObject() at System.Windows.Forms.ListView.OnGotFocus(EventArgs e) This is a follow up on dotnet#10910 (comment) Related to dotnet#4019
af5f665
to
b3ac40c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10934 +/- ##
===================================================
+ Coverage 62.72868% 62.74055% +0.01187%
===================================================
Files 1561 1562 +1
Lines 159997 159997
Branches 14918 14918
===================================================
+ Hits 100364 100383 +19
+ Misses 58857 58839 -18
+ Partials 776 775 -1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
Asked for a comment clarification.
return _accessibilityObject; | ||
} | ||
|
||
// Get ListView from the group item as a workaround for https://github.com/dotnet/winforms/issues/4019 |
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.
Can we explain this in addition to having the link?
src/System.Windows.Forms/System/Windows/Forms/Controls/ListView/ListViewGroup.cs
Outdated
Show resolved
Hide resolved
…w/ListViewGroup.cs
test failure is a duplicate of #13291 |
This fix is based on this call stack, I'm eliminating the top frame by creating this Accessibility object only when the parent control is available.
This is a follow up on #10910 (comment)
Related to #4019
I couldn't reproduce the issue, but the call stack is clear enough to understand the problem. There are situations when AccessibilityObject is not available, for example when the corresponding control is not displayed or not parented, thus changing nullability on this property. We were already guarding against accessing objects for "invisible" groups in the parent ListViewAccessibleObject when enumerating children.
We should not attempt to create accessible object for unparented ListView groups, for example when a group is removed from the control.
Microsoft Reviewers: Open in CodeFlow