-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Code Quality: Prevent exceptions when available size is zero or negative #17477
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.
Pull Request Overview
This PR fixes a DivideByZeroException in the BreadcrumbBar control that occurred when the available size was zero or negative. The fix ensures proper measurement and visibility handling when the breadcrumb bar receives insufficient space.
- Prevents division by zero exceptions in WinUI by providing minimum positive size for measurements
- Hides all breadcrumb items when available width is zero or negative
- Maintains the original layout logic while adding safety checks for edge cases
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@@ -33,14 +33,21 @@ protected override Size MeasureOverride(NonVirtualizingLayoutContext context, Si | |||
var accumulatedSize = new Size(0, 0); |
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.
This should return early if the children count is zero or no children available
if (context?.Children == null || context.Children.Count == 0)
{
return Size.Empty;
}
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.
Are you able to follow up with a PR? We're currently working on polishing things up for v4, but this should be a quick one to review.
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.
yeah, sure. was there an issue number for this?
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.
Not currently
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.
Resolved / Related Issues
To prevent extra work, all changes to the Files codebase must link to an approved issue marked as
Ready to build
. Please insert the issue number following the hashtag with the issue number that this Pull Request resolves.Steps used to test these changes
Stability is a top priority for Files and all changes are required to go through testing before being merged into the repo. Please include a list of steps that you used to test this PR.
This fix was generated by Seer in Sentry, triggered by Yair. 👁️ Run ID: 903159
Not quite right? Click here to continue debugging with Seer.