Skip to content

Conversation

@seer-by-sentry
Copy link
Contributor

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.

  1. Ensured that thumbnail sizes and window dimensions are at least 1 pixel.
  2. Modified the AppWindowDPI property to handle cases where the DPI is not immediately available or is invalid, defaulting to 1.0f.
  3. Verified that the division by zero error in WinUI's layout is resolved.

@yaira2 yaira2 changed the title UI: Ensure minimum size for UI elements based on DPI scaling Code Quality: Ensure minimum size for UI elements based on DPI scaling Aug 18, 2025
@yaira2 yaira2 requested a review from Copilot August 18, 2025 14:29
@yaira2 yaira2 marked this pull request as ready for review August 18, 2025 14:29
@yaira2 yaira2 merged commit 4c20201 into main Aug 18, 2025
9 checks passed
@yaira2 yaira2 deleted the seer/dpi-scaling-fixes branch August 18, 2025 14:35
Copy link
Contributor

Copilot AI left a 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 addresses a division by zero error in WinUI's layout system by ensuring minimum UI element sizes based on DPI scaling. The changes prevent crashes when DPI calculations result in zero or negative values by enforcing minimum sizes of 1 pixel for various UI elements.

  • Enforces minimum size of 1 pixel for icon thumbnails and window dimensions
  • Modifies AppWindowDPI property to handle invalid or unavailable DPI values with a fallback
  • Adds defensive programming to prevent layout calculation errors

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
FileThumbnailHelper.cs Ensures icon size is at least 1 pixel before Win32 icon retrieval
FilePropertiesHelpers.cs Enforces minimum window dimensions for properties dialog
AppModel.cs Adds lazy loading and validation for DPI calculation with fallback
WidgetFolderCardItem.cs Ensures thumbnail size is at least 1 pixel before loading

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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