Skip to content

qt: Handle fonts of deleted widgets properly, streamline the flow in GUIUtil::updateFonts - #3772

Merged
UdjinM6 merged 8 commits into
dashpay:developfrom
UdjinM6:fix3767
Oct 28, 2020
Merged

qt: Handle fonts of deleted widgets properly, streamline the flow in GUIUtil::updateFonts#3772
UdjinM6 merged 8 commits into
dashpay:developfrom
UdjinM6:fix3767

Conversation

@UdjinM6

@UdjinM6 UdjinM6 commented Oct 13, 2020

Copy link
Copy Markdown

Fixes #3767

Use QPointer-s to process deleted widgets properly, streamline the flow (less loops and map scans).
@UdjinM6 UdjinM6 added this to the 16.1 milestone Oct 13, 2020
@UdjinM6 UdjinM6 changed the title qt: Handle deleted widgets font properly, streamline the flow in GUIUtil::updateFonts qt: Handle fonts of deleted widgets properly, streamline the flow in GUIUtil::updateFonts Oct 13, 2020
@UdjinM6
UdjinM6 marked this pull request as ready for review October 13, 2020 14:57
@xdustinface

Copy link
Copy Markdown

@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 GUIUtil::updateFonts.

@UdjinM6

UdjinM6 commented Oct 22, 2020

Copy link
Copy Markdown
Author

@xdustinface Good catch! Cherry-picked them all 👍

@xdustinface xdustinface left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

Comment thread src/qt/guiutil.cpp
++nUpdatable;

QFont font = w->font();
assert(font.pointSize() > 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't love using asserts... If they do catch they provide basically no info to the user for us to debug with...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>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).

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@PastaPastaPasta PastaPastaPasta linked an issue Oct 27, 2020 that may be closed by this pull request
@UdjinM6
UdjinM6 merged commit e730732 into dashpay:develop Oct 28, 2020
UdjinM6 added a commit to UdjinM6/dash that referenced this pull request Oct 28, 2020
…`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>
@UdjinM6
UdjinM6 deleted the fix3767 branch November 26, 2020 13:26
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Mar 10, 2022
…`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>
thepastaclaw added a commit to thepastaclaw/dash that referenced this pull request Jul 29, 2026
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>
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.

[qt] Abnormal non-deterministic scaling of Settings text

3 participants