Skip to content

Conversation

@UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Feb 27, 2025

Issue being fixed or feature implemented

bitcoin-core/gui#336 backported in #6569 broke unlock dialog

What was done?

backport bitcoin-core/gui#509 to fix this

How Has This Been Tested?

Breaking Changes

Checklist:

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

This change is required for the following commits.
This change is required for the following commit.
The AskPassphraseDialog modal dialog must be synchronous here as
expected in the WalletModel::requestUnlock() function.

Fixed an introduced regression.
-BEGIN VERIFY SCRIPT-
sed -i 's/ShowModalDialogAndDeleteOnClose/ShowModalDialogAsynchronously/' -- $(git grep -l -e "ShowModalDialogAndDeleteOnClose")
-END VERIFY SCRIPT-

It is important to highlight that a modal dialog is showed
asynchronously as there are cases when the synchronous QDialog::exec()
is required.
@UdjinM6 UdjinM6 added this to the 23 milestone Feb 27, 2025
@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2025

Walkthrough

The changes refactor how dialogs are displayed and managed within the Qt-based UI. Calls to the function that presented modal dialogs and automatically deleted them upon closure have been replaced with a new asynchronous approach. This update is applied across multiple components, including address management, coin sending, transaction editing, and wallet interactions. In addition, the Bitcoin application now conditionally triggers shutdown detection only when no modal dialog is active. The refactoring also includes renaming several QAction objects for consistency and clarity in the Bitcoin GUI and removing some platform-specific tray icon activation code. In one instance related to wallet unlocking, the dialog is now stack-allocated and executed synchronously. Overall, these modifications aim to improve the control flow and user interaction experience with a more uniform dialog management approach across the application.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26ea618 and 8d6cfd7.

📒 Files selected for processing (10)
  • src/qt/addressbookpage.cpp (1 hunks)
  • src/qt/bitcoin.cpp (1 hunks)
  • src/qt/bitcoingui.cpp (9 hunks)
  • src/qt/bitcoingui.h (1 hunks)
  • src/qt/guiutil.cpp (1 hunks)
  • src/qt/guiutil.h (1 hunks)
  • src/qt/sendcoinsdialog.cpp (1 hunks)
  • src/qt/transactionview.cpp (2 hunks)
  • src/qt/walletframe.cpp (1 hunks)
  • src/qt/walletview.cpp (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: x86_64-w64-mingw32 / Build depends
  • GitHub Check: x86_64-apple-darwin / Build depends
  • GitHub Check: x86_64-pc-linux-gnu_nowallet / Build depends
  • GitHub Check: x86_64-pc-linux-gnu_multiprocess / Build depends
  • GitHub Check: x86_64-pc-linux-gnu / Build depends
  • GitHub Check: arm-linux-gnueabihf / Build depends
🔇 Additional comments (24)
src/qt/addressbookpage.cpp (1)

195-195: Dialog display method updated to use asynchronous approach.

The function call has been changed from ShowModalDialogAndDeleteOnClose to ShowModalDialogAsynchronously, aligning with the PR objective to respect dialog modality. This change maintains the modal behavior while allowing for asynchronous dialog management.

src/qt/walletframe.cpp (1)

291-291: Dialog display method updated to respect modality.

The function call has been changed from ShowModalDialogAndDeleteOnClose to ShowModalDialogAsynchronously, maintaining modal behavior while allowing for proper asynchronous dialog management. This change addresses the regression mentioned in the PR objectives.

src/qt/guiutil.h (1)

616-616: Function renamed to better reflect its actual behavior.

The function has been renamed from ShowModalDialogAndDeleteOnClose to ShowModalDialogAsynchronously. This change clarifies that the function displays a dialog modally but in an asynchronous manner, which is more descriptive of its actual behavior and helps address the dialog modality issues mentioned in the PR objectives.

src/qt/sendcoinsdialog.cpp (1)

943-943: Dialog display method updated for consistent behavior.

The function call has been changed from ShowModalDialogAndDeleteOnClose to ShowModalDialogAsynchronously, ensuring consistent dialog handling behavior across the application. This change aligns with the PR objective of respecting dialog modality.

src/qt/bitcoin.cpp (1)

262-267: Enhanced modal dialog handling to prevent shutdown detection during active dialog interaction

The change adds a conditional check before calling detectShutdown() to ensure it's not triggered while a modal dialog is active. This prevents potential issues where shutdown detection might interfere with active user interactions in modal dialogs.

src/qt/transactionview.cpp (2)

519-520: Updated dialog display method for more consistent modal dialog handling

Replaced ShowModalDialogAndDeleteOnClose with ShowModalDialogAsynchronously for better naming clarity while maintaining the same functionality.


528-529: Updated dialog display method for more consistent modal dialog handling

Same change as above, replacing ShowModalDialogAndDeleteOnClose with ShowModalDialogAsynchronously for better naming clarity.

src/qt/guiutil.cpp (1)

1953-1958: Renamed function for better clarity of behavior

The function has been renamed from ShowModalDialogAndDeleteOnClose to ShowModalDialogAsynchronously to better describe its actual behavior. The implementation remains the same: setting the dialog to delete on close and making it application modal. This change improves code readability and maintainability.

src/qt/walletview.cpp (3)

302-303: Updated dialog display method for encryption dialog

Replaced ShowModalDialogAndDeleteOnClose with ShowModalDialogAsynchronously for consistent dialog handling.


329-330: Updated dialog display method for passphrase dialog

Replaced ShowModalDialogAndDeleteOnClose with ShowModalDialogAsynchronously for consistent dialog handling.


336-341: Fixed wallet unlock dialog handling

The unlock dialog implementation has been changed from an asynchronous approach to a synchronous one, which correctly aligns with the expectations of the WalletModel::requestUnlock() function. This change uses stack allocation instead of heap allocation and blocks until the dialog is closed with dlg.exec(), ensuring proper control flow.

This is a key fix for the regression in wallet unlock mentioned in the PR title.

src/qt/bitcoingui.h (2)

146-148: Action variables renamed for consistency.

The QAction pointer variables for coin operations have been renamed to follow a more consistent naming pattern, dropping the "Menu" part:

  • sendCoinsMenuActionsendCoinsAction
  • coinJoinCoinsMenuActioncoinJoinCoinsAction

155-155: Action variable renamed for consistency.

The QAction pointer for receiving coins has been renamed to follow the same pattern as the other coin action variables:

  • receiveCoinsMenuActionreceiveCoinsAction
src/qt/bitcoingui.cpp (11)

357-367: Updated action initialization to match new variable names.

The initialization of QAction pointers has been updated to match the renamed variables in the header file. This ensures consistent naming throughout the codebase.


371-376: Updated signal connections for the renamed action variables.

The connections between signals and slots have been updated to use the new action variable names. This maintains the same functionality while using the renamed variables.


682-684: Updated references to use the action properties.

Instead of hard-coding the text and status tip, the code now references the properties from the corresponding action. This improves maintainability by centralizing the text in one place.


687-689: Improved code reuse by referencing action properties.

Similar to the send coins button, the receive coins button now references the text and status tip from its corresponding action, improving consistency and maintainability.


697-699: Updated CoinJoin button to reference action properties.

The CoinJoin button now also references its corresponding action's text and status tip, completing the pattern of improvement across all coin operation buttons.


794-812: Improved tray icon and dock icon handling.

The code has been refactored to:

  1. Use lambda functions for better readability and maintainability
  2. Separate platform-specific behavior more clearly
  3. Remove the need for separate platform-specific methods in the header file

This change maintains the same functionality while simplifying the code structure.


1000-1006: Updated wallet actions enablement code for renamed variables.

The wallet actions enablement code has been updated to use the renamed action variables, ensuring consistency with the rest of the renamed variables.


1036-1113: Refactored icon menu creation with improved error handling.

The icon menu creation has been significantly refactored to:

  1. Use more descriptive variable names
  2. Better handle modal dialogs by disabling menu items when a modal dialog is active
  3. Use lambda functions for more readable connections
  4. Separate platform-specific code more clearly

This enhances user experience by preventing actions that would be blocked by an active modal dialog.


1126-1126: Fixed dialog handling to respect modality.

The key change in this PR: changing from ShowModalDialogAndDeleteOnClose to ShowModalDialogAsynchronously. This fixes the regression in wallet unlock dialog functionality by properly respecting dialog modality.

This change addresses the core issue described in the PR objectives, ensuring that modal dialogs work as expected.


1388-1388: Updated options dialog to use asynchronous modal dialog handling.

Consistent with the change in the about dialog, the options dialog now also uses the asynchronous modal dialog handling approach.


1423-1423: Updated visibility control for CoinJoin action.

The coinJoinCoinsAction visibility is now correctly updated when the CoinJoin feature is enabled or disabled, consistent with the UI update pattern used elsewhere.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Collaborator

@knst knst left a comment

Choose a reason for hiding this comment

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

LGTM but check comment about fForMixingOnly

coinJoinCoinsMenuAction = new QAction(QString("&%1").arg(strCoinJoinName), this);
coinJoinCoinsMenuAction->setStatusTip(tr("Send %1 funds to a Dash address").arg(strCoinJoinName));
coinJoinCoinsMenuAction->setToolTip(coinJoinCoinsMenuAction->statusTip());
coinJoinCoinsAction = new QAction(QString("&%1").arg(strCoinJoinName), this);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: maybe split this renaming to own commit?

Copy link
Author

Choose a reason for hiding this comment

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

The original commit bitcoin-core/gui@58e1603 dropped *MenuActions and kept other actions. But we don't have other actions, we already use one action where bitcoin uses two (before this backport). If I'd rename these actions beforehand, then the backported commit would not do what it say it does ("drop members") cause there would be nothing to drop 🤷‍♂️

auto dlg = new AskPassphraseDialog(AskPassphraseDialog::Unlock, this);
dlg->setModel(walletModel);
GUIUtil::ShowModalDialogAndDeleteOnClose(dlg);
AskPassphraseDialog dlg(AskPassphraseDialog::Unlock, this);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems as gui#336 introduced one extra bug: there's missing usage of flag fForMixingOnly

This line should be:

AskPassphraseDialog dlg(fForMixingOnly ? AskPassphraseDialog::UnlockMixing : AskPassphraseDialog::Unlock, this);

Copy link
Author

Choose a reason for hiding this comment

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

Oh, wow. Good catch! 👍

Copy link
Collaborator

@knst knst left a comment

Choose a reason for hiding this comment

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

LGTM 86cdd24

Copy link
Collaborator

@kwvg kwvg left a comment

Choose a reason for hiding this comment

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

ACK 86cdd24

@PastaPastaPasta PastaPastaPasta merged commit 5e68b5b into dashpay:develop Mar 4, 2025
33 of 35 checks passed
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.

5 participants