Skip to content

Conversation

@kwvg
Copy link
Collaborator

@kwvg kwvg commented Dec 29, 2025

Additional Information

dash#7068 introduced a regression where Qt clients with no GUI settings are unable to run at all due to failed weight to index conversion. This was covered in 9cd9d44 but made an incorrect assumption that earlier iterations of the fix (see ef34868) did not make.

The assumption made that resulted in this regression was that if the argument to weight conversion is successful, then the weight to index conversion will also be successful.

The earlier iteration of the fix checked the return value of the index conversion and set a sane default if it was invalid. The final iteration set the default weight value to the sane weight, expecting weightFromArg() to fail (hence using the sane weight), not supportedWeightToIndex() (which might not be able to process even a valid weight from argument).

This was not caught in testing as over the course of working on dash#6833, my GUI settings were migrated to settings.json, which has precedence over QSettings and therefore, the client always ran with known good Montserrat parameters.

Fix can be verified by deleting your QSettings parameters and running the client anew.

Breaking Changes

None expected.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas (note: N/A)
  • I have added or updated relevant unit/integration/functional/e2e tests (note: N/A)
  • I have made corresponding changes to the documentation (note: N/A)
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@kwvg kwvg added this to the 23.1 milestone Dec 29, 2025
@github-actions
Copy link

github-actions bot commented Dec 29, 2025

✅ No Merge Conflicts Detected

This PR currently has no conflicts with other open PRs.

@coderabbitai
Copy link

coderabbitai bot commented Dec 29, 2025

Walkthrough

The data() method mapping for FontWeightNormal and FontWeightBold in optionsmodel.cpp has been modified to validate computed font weights using IsValidWeight before converting to an index. If the computed weight is invalid, the method now falls back to the registry's default weight for the corresponding style via a lambda. Previously, weights were computed and converted directly to indices without an explicit validity check.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and specifically describes the main bug fix: correcting an invalid assumption that successful weight conversion guarantees a valid index.
Description check ✅ Passed The description provides comprehensive context explaining the regression, the root cause, how it was introduced, and how to verify the fix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 297c9cc and 8bba1d2.

📒 Files selected for processing (1)
  • src/qt/optionsmodel.cpp
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.{cpp,h,hpp,cc}

📄 CodeRabbit inference engine (CLAUDE.md)

Dash Core implementation must be written in C++20, requiring at least Clang 16 or GCC 11.1

Files:

  • src/qt/optionsmodel.cpp
src/qt/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

GUI implementation in src/qt/ must use Qt 5

Files:

  • src/qt/optionsmodel.cpp
🧠 Learnings (3)
📓 Common learnings
Learnt from: kwvg
Repo: dashpay/dash PR: 7068
File: src/qt/guiutil_font.h:68-77
Timestamp: 2025-12-22T15:42:51.679Z
Learning: In the Dash Core Qt codebase (src/qt/guiutil_font.h), kwvg intentionally uses `assert()` in setter methods like `SetWeightBold` and `SetWeightNormal` to enforce invariants (e.g., `assert(m_weights.count(m_font))`). This fail-fast approach is preferred over defensive checks with fallbacks when an inconsistent state indicates a programming error that should be caught during development, rather than a runtime condition requiring graceful handling.
📚 Learning: 2025-12-22T15:42:51.679Z
Learnt from: kwvg
Repo: dashpay/dash PR: 7068
File: src/qt/guiutil_font.h:68-77
Timestamp: 2025-12-22T15:42:51.679Z
Learning: In the Dash Core Qt codebase (src/qt/guiutil_font.h), kwvg intentionally uses `assert()` in setter methods like `SetWeightBold` and `SetWeightNormal` to enforce invariants (e.g., `assert(m_weights.count(m_font))`). This fail-fast approach is preferred over defensive checks with fallbacks when an inconsistent state indicates a programming error that should be caught during development, rather than a runtime condition requiring graceful handling.

Applied to files:

  • src/qt/optionsmodel.cpp
📚 Learning: 2025-12-17T13:58:19.813Z
Learnt from: kwvg
Repo: dashpay/dash PR: 7072
File: src/qt/walletcontroller.cpp:520-528
Timestamp: 2025-12-17T13:58:19.813Z
Learning: In Dash Qt wallet code, prefer using existing Qt signals/slots (e.g., ShowProgress signals) for long-running operations instead of adding explicit QProgressDialog dialogs. This minimizes upstream deviations and simplifies backports. Apply this pattern to wallet-related Qt components (e.g., operations like rescanning) and rely on signal-based progress updates rather than bespoke dialogs.

Applied to files:

  • src/qt/optionsmodel.cpp
🧬 Code graph analysis (1)
src/qt/optionsmodel.cpp (1)
src/qt/guiutil_font.cpp (2)
  • weightFromArg (168-176)
  • weightFromArg (168-168)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Lint / Run linters
  • GitHub Check: Build container / Build container (arm64)
  • GitHub Check: Build container / Build container (amd64)
🔇 Additional comments (2)
src/qt/optionsmodel.cpp (2)

566-575: LGTM! Correct fix for weight-to-index validation.

The lambda correctly validates that the weight from settings is both successfully converted AND supported by the current font before converting to an index. The fallback to GetWeightNormalDefault() is appropriate for cases where the stored weight is not supported, fixing the regression where clients with missing QSettings could fail to start.


576-585: LGTM! Consistent validation for bold weight.

The implementation mirrors the FontWeightNormal fix, correctly validating both the weight conversion and font support before using it. The fallback to GetWeightBoldDefault() ensures robust behavior when stored weights are invalid or unsupported.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

utACK 8bba1d2

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK 8bba1d2

@PastaPastaPasta PastaPastaPasta merged commit c404597 into dashpay:develop Dec 30, 2025
42 of 46 checks passed
PastaPastaPasta added a commit that referenced this pull request Jan 3, 2026
…nt font for overview page balances)

636e7a6 refactor: remove redundant preview and simplify font handling (UdjinM6)
b59b0f7 feat(qt): add live preview for monospace font in appearance settings (UdjinM6)
83af951 fix: set money font when setting wallet model instead of ctor (Kittywhiskers Van Gogh)
658905b qt: add non-monospace option and use it as default (Kittywhiskers Van Gogh)
e0513ff qt: add horizontal spacer for visual consistency (Kittywhiskers Van Gogh)
e5a8d05 refactor: move monospace font selector to appearance widget (Kittywhiskers Van Gogh)
41c69e9 merge bitcoin-core/gui#497: Enable users to configure their monospace font specifically (Kittywhiskers Van Gogh)
da5804e merge bitcoin-core/gui#79: Embed monospaced font (Kittywhiskers Van Gogh)
eac4f52 qt: adjust padding and font size of monospace font selector (Kittywhiskers Van Gogh)
9c315c3 qt: add monospaced font settings (Kittywhiskers Van Gogh)
34211b6 qt: apply monospace font to overview page balances and CoinJoin elements (Kittywhiskers Van Gogh)
6ed53d6 qt: allow overriding font registry for specific widgets (Kittywhiskers Van Gogh)
800cf66 qt: recognize system monospace font as non-selectable font (Kittywhiskers Van Gogh)
85b49b9 qt: add "Roboto Mono" as non-selectable font (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  * Depends on #7068

  * Depends on #7084

  * Dependency for #6833

  | [dash#7084](#7084) (8bba1d2)  | This PR (636e7a6) |
  | ------------------- | ------------------- |
  | ![image](https://github.com/user-attachments/assets/0208ffb7-d511-4211-a304-6a0aa4d6c367) | ![image](https://github.com/user-attachments/assets/d1f42ec7-f1ee-4856-9c42-04b4c0b103aa) |
  | ![image](https://github.com/user-attachments/assets/1ce9c72b-d6a1-43ed-b86d-d76cbd52f2b8) | ![image](https://github.com/user-attachments/assets/e8e6bae2-1825-4132-9f78-385dbda31a61) |
  | ![image](https://github.com/user-attachments/assets/fac6e70f-1ebb-407b-bd16-85ea8ebef84f) | ![image](https://github.com/user-attachments/assets/b8f1d5f8-63a1-4e50-8314-0bc29000959a) |

  * Based on review suggestions given ([comment](#6831 (comment))), [bitcoin-core/gui#497](bitcoin-core/gui#497) was also backported to allow arbitrary font specification. This also allowed us to offer a "Use existing font" option that _doesn't_ use any monospace font but instead inherits whatever font is used in the rest of the application. This is set as the default ([source](https://github.com/kwvg/dash/blob/89aa2c4b2390ada504fd5b45e16d2cd379074138/src/qt/optionsmodel.cpp#L73)), rendering monospace balance counters opt-in.

  * Unlike Bitcoin, Dash has a dedicated appearance widget for managing font settings specifically. We have opted to deviate from upstream by moving the money font control from "Display" to "Appearance" for the sake of consistency.

  * We set the money font when setting the wallet model as client model updates happen after the UI is visible to the user while wallet model updates happen _before_, there is little point in setting them to any values in the constructor as during construction, we don't have access to the options model and thus don't know _what_ font is supposed to be used to begin with.

  * If a font is passed through the command line, it is considered "selectable" ([source](https://github.com/kwvg/dash/blob/89aa2c4b2390ada504fd5b45e16d2cd379074138/src/qt/bitcoin.cpp#L676-L679)) because we still need to populate that font in the drop-down menu so that we don't report stale data. Though, the font cannot be _set_ to that overridden value because command-line overridden controls are auto-disabled to prevent settings corruption (see 2f30002), which makes the "selectable" state more-or-less an internal detail.

    An example is that the user tries to run Dash Core, the embedded monospace font, Roboto Mono, is _not_ a selectable font (i.e. you cannot ordinarily set your client to use Roboto Mono, see below).

    <details>

    <summary>Screenshot:</summary>

    ![image](https://github.com/user-attachments/assets/cf005084-c184-4c61-8d37-4106102108f1)

    </details>

    But if an override is done, it will be respected, the client will start with Roboto Mono and the selectable status will be overwritten so that it is presented in the drop-down menu, albeit, with the menu disabled so it doesn't contaminate UI settings.

    <details>

    <summary>Screenshot:</summary>

    ![image](https://github.com/user-attachments/assets/a4479dc3-60e0-4c8b-bf41-f89ce2012539)

    </details>

  ## Breaking Changes

  None expected.

  ## Checklist

  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas
  - [x] I have added or updated relevant unit/integration/functional/e2e tests **(note: N/A)**
  - [x] I have made corresponding changes to the documentation **(note: N/A)**
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    ACK 636e7a6

Tree-SHA512: a8b23c14aec0ccac126bdc7a6db0a4583da3bda52e02f72d213431bbaa80c633a432ed02c4a33d71e3e4d2503d076624196c3e6e50c9bb7fd8e3b50ae4e9ec35
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.

3 participants