fix(qt): handle pixel-sized fonts when scaling widgets#7315
fix(qt): handle pixel-sized fonts when scaling widgets#7315thepastaclaw wants to merge 1 commit into
Conversation
✅ No Merge Conflicts DetectedThis PR currently has no conflicts with other open PRs. |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
✅ Review complete (commit 9c94795) |
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis change improves the robustness of font size detection in Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
Small, focused Qt fix replacing a fatal assert with a graceful pixel-to-point conversion path for stylesheet-driven pixel-sized fonts. Logic is sound; idempotency via mapWidgetDefaultFontSizes::emplace is preserved. No blocking issues — only two low-impact nitpicks worth surfacing.
Reviewed commit: 9c94795
💬 2 nitpick(s)
| if (font_size <= 0 && font.pixelSize() > 0) { | ||
| font_size = font.pixelSize() * 72.0 / w->logicalDpiY(); | ||
| font.setPointSizeF(font_size); | ||
| } |
There was a problem hiding this comment.
💬 Nitpick: setPointSizeF on line 585 is redundant
The local font is either fully replaced by getFont(...) on line 604 (when an entry exists in mapFontUpdates) or has its size overwritten by setPointSizeF(GetScaledFontSize(...)) on line 606. The explicit font.setPointSizeF(font_size) on line 585 has no observable effect on the font ultimately stored in mapWidgetFonts or compared at line 609. Removing it would tighten the code; keeping it is harmless as a defensive normalization.
source: ['claude']
| if (font_size <= 0 && font.pixelSize() > 0) { | ||
| font_size = font.pixelSize() * 72.0 / w->logicalDpiY(); | ||
| font.setPointSizeF(font_size); | ||
| } | ||
| if (font_size <= 0) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
💬 Nitpick: logicalDpiY() result is cached for the lifetime of the widget
w->logicalDpiY() correctly reports the DPI of the widget's current screen, but the derived point-size is then cached in mapWidgetDefaultFontSizes as the widget's 'default font size'. If the widget later migrates to a screen with a different DPI, the cached value will no longer correspond to the original pixel size. The same caching limitation exists in the pre-PR code paths, so this is not a regression — just a corner case worth noting.
source: ['claude']
Pixel-sized font scaling fix
Summary
GUIUtil::updateFonts()runsfont-scaling path
Fixes #7281.
Validation
git diff --check upstream/develop...HEADshipforupstream/develop..tracker-1251to reproduce the original crash locally.