Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged

Conversation

Tanya-Solyanik
Copy link
Member

@Tanya-Solyanik Tanya-Solyanik commented Feb 22, 2024

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.

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 #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

@Tanya-Solyanik Tanya-Solyanik changed the title Intermittent exception when creating a ListViewAccessibleObject Intermittent exception when creating a ListViewGroupAccessibleObject Feb 22, 2024
@dotnet-policy-service dotnet-policy-service bot added the draft draft PR label Feb 22, 2024
@Tanya-Solyanik Tanya-Solyanik force-pushed the Null-Ref-ListViewAccessibleObject branch from babced7 to af5f665 Compare April 24, 2025 21:55
…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
@Tanya-Solyanik Tanya-Solyanik marked this pull request as ready for review April 29, 2025 22:32
@Tanya-Solyanik Tanya-Solyanik requested a review from a team as a code owner April 29, 2025 22:32
@Tanya-Solyanik Tanya-Solyanik force-pushed the Null-Ref-ListViewAccessibleObject branch from af5f665 to b3ac40c Compare April 29, 2025 22:32
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.74055%. Comparing base (5f9458e) to head (bc2373e).
Report is 8 commits behind head on main.

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     
Flag Coverage Δ
Debug 62.74055% <ø> (+0.01187%) ⬆️
integration 11.34158% <ø> (+0.00732%) ⬆️
production 40.93892% <ø> (+0.01973%) ⬆️
test 95.70296% <ø> (ø)
unit 38.33773% <ø> (+0.01557%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dotnet-policy-service dotnet-policy-service bot removed the draft draft PR label Apr 30, 2025
Copy link
Member

@JeremyKuhne JeremyKuhne left a 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
Copy link
Member

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?

@Tanya-Solyanik
Copy link
Member Author

test failure is a duplicate of #13291

@Tanya-Solyanik Tanya-Solyanik enabled auto-merge (squash) May 1, 2025 19:34
@Tanya-Solyanik Tanya-Solyanik merged commit 9be7da7 into dotnet:main May 1, 2025
8 checks passed
@Tanya-Solyanik Tanya-Solyanik deleted the Null-Ref-ListViewAccessibleObject branch May 2, 2025 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants