-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix IndexOutOfRangeException/Infinite loop in UpdateComponent (Track control) #9934
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
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.
LGTM.
@h3xds1nz this PR is good to be merged. Can you please resolve the merge conflicts? |
089d413
to
309e50c
Compare
@himgoyalmicro Done :) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9934 +/- ##
===================================================
+ Coverage 10.99508% 11.42314% +0.42806%
===================================================
Files 3215 3214 -1
Lines 648472 648613 +141
Branches 71534 71527 -7
===================================================
+ Hits 71300 74092 +2792
+ Misses 576170 573359 -2811
- Partials 1002 1162 +160
Flags with carried forward coverage won't be shown. Click here to find out more. |
Thank you, @h3xds1nz, for your consistent and valuable contributions. Your hard work is greatly appreciated! 😄 |
@himgoyalmicro Thank you for continuously approving :) |
Fixes #9904
Description
Fixes
IndexOutOfRangeException
and infinite loop issues when updating any ofTrack
's children after they've been already set from template or manually.This issue is present when you attempt to update via any of the public properties (
DecreaseRepeatButton
,IncreaseRepeatButton
,Thumb
) after all the public members of Track has already been previously set (and therefore_visualChildren
is initialized and has stored all three properties).In standard Aero2 theme, using a
ScrollBar
(asTrack
has no template on its own), the order of the children is:Setting item at position 2 (which would be
Thumb
property now) will result in an infinite loop.Setting items at positions 0 and 1 will result in
IndexOutOfRangeException
during assigment.The simplest reproduction code with pure
Track
goes like this:The original code was written with updates in mind but I think it got a bit lost in shifting array members. I have fixed it to behave exactly as described in Track.GetVisualChild and Track.VisualChildrenCount describes (+ the original comments), that means whenever you update an item, the array is shifted to the left if needed, so the order is always from oldest to newest (left to right).
This is aligned with
VisualChildrenCount
behavior whereNULL
allows you to remove children basically as well.Customer Impact
Customers will be finally able to change the
Track
components as they please and won't experience undocumented behavior and exceptions that were not originally inteded.Regression
This seems to be present way back. PresentationFramework v3 from NetFX has a bit different code but also buggy.
Testing
Testing the forementioned exceptions and the order of the items, visual refresh, everything seems in order.
Risk
Low, a loop has been fixed to work properly without changing anything else (e.g. collection types, etc.)
Microsoft Reviewers: Open in CodeFlow