qt: Handle fonts of deleted widgets properly, streamline the flow in GUIUtil::updateFonts - #3772
Conversation
Use QPointer-s to process deleted widgets properly, streamline the flow (less loops and map scans).
GUIUtil::updateFontsGUIUtil::updateFonts
|
@UdjinM6 I can confirm this solves the issues pointed out in #3767 (FYI, i was able to reproduce it on macOS also). But this fix introduces a new scaling bug due to font inheritance (Just start the wallet with a very low/high font scale to reproduce it in most screens). See suggestion-3772 which contains a fix (8c075b9) for the introduced issue and also some more refactoring in |
The "Normal" was added when we also had other maps containing font updates
|
@xdustinface Good catch! Cherry-picked them all 👍 |
| ++nUpdatable; | ||
|
|
||
| QFont font = w->font(); | ||
| assert(font.pointSize() > 0); |
There was a problem hiding this comment.
I really don't love using asserts... If they do catch they provide basically no info to the user for us to debug with...
There was a problem hiding this comment.
>0 means that it's either a default font size (set via setApplicationFont) or some another valid value and font size was not set via setPixelSize. IMO it's safe to use it here, should only crash if we break smth in code (e.g. use setPixelSize).
…`GUIUtil::updateFonts` (dashpay#3772) * Refactor and fix `GUIUtil::updateFonts` Use QPointer-s to process deleted widgets properly, streamline the flow (less loops and map scans). * Add some debug output * qt: Rename mapNormalFontUpdates -> mapFontUpdates The "Normal" was added when we also had other maps containing font updates * qt: Count removed items, adjust debug logs * qt: Use the emplace result for the default font size * qt: Perform all widget font updates later in a seperate step * qt: Drop pointSize checks * qt: Refactor app class font scaling Co-authored-by: xdustinface <xdustinfacex@gmail.com>
…`GUIUtil::updateFonts` (dashpay#3772) * Refactor and fix `GUIUtil::updateFonts` Use QPointer-s to process deleted widgets properly, streamline the flow (less loops and map scans). * Add some debug output * qt: Rename mapNormalFontUpdates -> mapFontUpdates The "Normal" was added when we also had other maps containing font updates * qt: Count removed items, adjust debug logs * qt: Use the emplace result for the default font size * qt: Perform all widget font updates later in a seperate step * qt: Drop pointSize checks * qt: Refactor app class font scaling Co-authored-by: xdustinface <xdustinfacex@gmail.com>
updateFonts() sweeps every widget in the application and asserted that each one reported a positive point size. Widgets sized in pixels report -1, so the assert fired and aborted the process. assert() is live in release builds here -- src/util/check.h refuses to compile with NDEBUG -- so this was a crash in shipped binaries, not a debug-only check. The trigger is in the shipped stylesheet: general.css sizes MnemonicVerificationDialog's warningLabel and instructionLabel with `font-size: 17px` / `14px`. QDialog is in vecIgnoreClasses but QLabel is not, so those labels are swept. Qt writes the stylesheet's font into the widget's own font, which is what the sweep reads. (QGroupBox's `font-size: 16px` rule looks like a second trigger but is not: QGroupBox is ignored, and a pixel size on it does not propagate to its children.) The assert was never a designed invariant. 634ccc8 added it while a working defaultFontSize fallback still handled this case, and c6bf0d3 removed that fallback the same day, leaving the assert as the sole handler -- a regression from dashpay#3772. Skip the widget when no size can be derived rather than substituting a default, which would resize a widget the stylesheet deliberately sized. The counter is moved below the check so it keeps reflecting the widgets actually considered updatable. Seeding the per-widget cache from pointSizeF() rather than pointSize() also completes cdd7b37 ("refactor: consolidate font attributes to struct"), which widened this map and its consumer from int to double but left the producer truncating, silently discarding the fractional part on every pass. Fixes dashpay#7281 Fixes dashpay#7464 Co-Authored-By: Claude <noreply@anthropic.com>
Fixes #3767