Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect dialog modality and fix a regression in wallet unlock #509

Merged
merged 11 commits into from
Feb 15, 2022

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Dec 17, 2021

As pointed in bitcoin/bitcoin#23790 a regression in wallet unlock was introduced in #336 when a synchronous AskPassphraseDialog has been replaced with an asynchronous one.

This PR reverts a call back to a synchronous mode.

To make synchronous dialogs behave nice during shutdown some additional changes were made.

Please note that disabling the tray icon menu when a modal dialog is active is useful itself as on master (4ad5904) it is possible to switch to the "Receive" tab while the GUI is waiting for a password for the "Send" tab:

Screenshot from 2021-12-17 18-59-51

This is confusing and must be avoided.

Fixes bitcoin/bitcoin#23790.

@ghost
Copy link

ghost commented Dec 17, 2021

I was unable to reproduce the issue mentioned in bitcoin/bitcoin#23790 using PR branch, so issue might be fixed. There was a password prompt each time I tried to send bitcoin from an encrypted wallet.

image

Would like to test few more things and go through each commit since there are 11 commits in this PR before ACK

@willyko
Copy link
Contributor

willyko commented Dec 18, 2021

testedACK for the issue mentioned in bitcoin/bitcoin#23790

@hebasto
Copy link
Member Author

hebasto commented Dec 18, 2021

Updated 702a243 -> 80e7e30 (pr509.01 -> pr509.02, diff).

Dropped QAction::setStatusTip() calls:

  • status tip works only for top-level parent widget, tray icon's QMenu instance is not a top-level one
  • even on master this feature does not work consistently across all supported platforms
  • the tray icon context menu is not local to the main window status bar, so status tips are likely to be unnoticed by users

@ghost
Copy link

ghost commented Dec 21, 2021

Is this error related to this PR in any way? UPDATE: Its not related to PR. I tried testing this with 1 commit removed from PR branch in #399 but still got same error so I will create new issue for this.

image

I get this when I try to load a PSBT for signing. This does not happen in v22.0

PSBT:

cHNidP8BAFICAAAAAYLWIrucosFvAaD6/JAOgihjyt2xcshd2VdRQd2VUknSAAAAAAD9////ARAnAAAAAAAAFgAUX2caQkxHKburbHQctmMM7btDNunWiiAAAAEA3gIAAAAAAQE6UEKkqOk4pmFFsjgCdJWcr8o/e05sonzbu2r9WuUNIAEAAAAA/f///wINKAAAAAAAABYAFOgtXS/Ov298HhtS87BZe0K/OQ8ooIYBAAAAAAAWABQqd5hFsp4qwKj0vyfuSRN8nFEBoAJHMEQCIBIgXxY+MF/b4MsjbK3D1zE1bcrsIFYNOEA8WmHwAGZeAiBarlG/F19lu3vRY9YznD3rBy6pF5RnjSitGdxUpIml9wEhAhtZklcfD/gpfbAtqeqetj+NSHzadZkQp2+odLAQEp/lp4cgAAAA

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

tACK 80e7e30

This PR fixes the bug reported in bitcoin/bitcoin#23790 and I did not find any issues with the code or testing other things.

@ghost
Copy link

ghost commented Dec 24, 2021

There is some error in CI though which I missed earlier: https://github.com/bitcoin-core/gui/pull/509/checks?check_run_id=4570631121

@ghost ghost mentioned this pull request Dec 24, 2021
@hebasto
Copy link
Member Author

hebasto commented Dec 26, 2021

Updated 80e7e30 -> 356e21f (pr509.02 -> pr509.03, diff).

Silenced -Wunused-variable warnings for macOS.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

reACK 356e21f

@promag
Copy link
Contributor

promag commented Jan 5, 2022

@hebasto have you tried to fix the regression without reverting the other change?

@hebasto
Copy link
Member Author

hebasto commented Jan 5, 2022

@promag

@hebasto have you tried to fix the regression without reverting the other change?

Yes. Although, did not finish it. Changes got more and more evolved.

@promag
Copy link
Contributor

promag commented Jan 10, 2022

@hebasto I can see why, there are multiple cases. Not sure how I didn't catch unlockWallet blocking case on #336 (review) review.

I think the best course of action is to revert and follow up with necessary refactors.

Concept ACK.

Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

tACK 356e21f

Verified that the error mentioned in bitcoin/bitcoin#23790 happens in master branch and this PR fixes it.

@hebasto hebasto requested a review from achow101 January 24, 2022 08:12
Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

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

a632303 indeed fixes the no lock after send regression for me. But it introduces some (much less problematic) regressions, at least on macOS.

sign_action->setEnabled(signMessageAction->isEnabled());
verify_action->setEnabled(verifyMessageAction->isEnabled());
if (QApplication::activeModalWidget()) {
for (QAction* a : trayIconMenu.get()->actions()) {
Copy link
Member

Choose a reason for hiding this comment

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

97692af: I don't see any difference in behavior on macOS; before and after this commit, if I open coin selection, it disables everything except the macOS standard items (Options, Show all windows, Hide, Stop)

@@ -265,7 +265,11 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
connect(window, &BitcoinGUI::quitRequested, this, &BitcoinApplication::requestShutdown);

pollShutdownTimer = new QTimer(window);
connect(pollShutdownTimer, &QTimer::timeout, window, &BitcoinGUI::detectShutdown);
connect(pollShutdownTimer, &QTimer::timeout, [this]{
Copy link
Member

@Sjors Sjors Feb 8, 2022

Choose a reason for hiding this comment

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

cda881a : on macOS when I'm in coin control, before and after this commit, Command + Q is ignored (not delayed). Same with Stop from the tray menu. (that's fine by the way, a delayed shutdown seems confusing)

But when I hit ctrl + c in the terminal, before this commit it would shut QT down, with this commit it indeed delays the shutdown until the dialog is closed. (that's also fine, because this method of shutdown is probably only used by developers)

@hebasto hebasto marked this pull request as draft February 8, 2022 16:29
@hebasto hebasto marked this pull request as ready for review February 8, 2022 16:43
Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

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

tACK 74e638a

if (show_hide_action) show_hide_action->setText(
(!isHidden() && !isMinimized() && !GUIUtil::isObscured(this)) ?
tr("&Hide") :
tr("S&how"));
Copy link
Member

Choose a reason for hiding this comment

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

fd667e7: you may want to delay this keyboard shortcut, because we're past the translation cut-off?

@hebasto
Copy link
Member Author

hebasto commented Feb 9, 2022

@Sjors

you may want to delay this keyboard shortcut, because we're past the translation cut-off?

Change is small, so it's okay to get it merged before string freeze (now we are in "soft translation string freeze").

@prayank23 @w0xlt @promag

Mind having another look into this PR?

@hebasto
Copy link
Member Author

hebasto commented Feb 9, 2022

On macOS another behavior change noticed. On master, due to

optionsAction->setMenuRole(QAction::PreferencesRole);
optionsAction has forcibly been hidden in the Dock menu (according to design guide, it is moved into application menu):

Screenshot from 2022-02-09 06-49-29

With this PR options_action has no QAction::PreferencesRole set, and it is active:

Screenshot from 2022-02-09 06-56-51

@Sjors What do think about this behavior change?

@Sjors
Copy link
Member

Sjors commented Feb 9, 2022

It seems confusing to have "Options..." and "Options ->" in a single dropdown. I don't care deeply, but maybe just keep the original behavior?

@ghost
Copy link

ghost commented Feb 10, 2022

@prayank23 @w0xlt @promag

Mind having another look into this PR?

I don't care about UI issues with Mac but this pull request addresses an issue which affects security on every platform, works as expected so I have no issues with it. Would have been better if reverting changes were simple and less line of code in this PR. Hopefully we don't ship v23.0 with a known issue that affects security.

ACK 74e638a

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.
@hebasto
Copy link
Member Author

hebasto commented Feb 12, 2022

Updated 74e638a -> f730bd7 (pr509.04 -> pr509.05, diff).

It seems confusing to have "Options..." and "Options ->" in a single dropdown. I don't care deeply, but maybe just keep the original behavior?

Fixed.

@hebasto
Copy link
Member Author

hebasto commented Feb 14, 2022

@prayank23 @Sjors

Would you mind re-acking?

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

tACK f730bd7

Tried on Fedora and found no issues.

image

@hebasto hebasto requested a review from jarolrod February 14, 2022 22:24
@hebasto hebasto merged commit 1695d66 into bitcoin-core:master Feb 15, 2022
@hebasto hebasto deleted the 211217-unlock branch February 15, 2022 06:39
@Sjors
Copy link
Member

Sjors commented Feb 15, 2022

Post merge tACK, only difference is the PreferencesRole and the duplicate Options is gone.

@jarolrod
Copy link
Member

Post merge tACK, I was able to reproduce the original issue and I've done testing to ensure that this PR fixes this.

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 15, 2022
laanwj added a commit that referenced this pull request Feb 22, 2022
c515829 qt: Update translation source file (Hennadii Stepanov)

Pull request description:

  As the part of the v23.0 [release process](bitcoin/bitcoin#22969) this PR updates translation source file, `src/qt/locale/bitcoin_en.xlf`.

  The following changes are reflected in this PR:
  - small string changes from #509
  - internal technical details from bitcoin/bitcoin#22151

ACKs for top commit:
  laanwj:
    ACK c515829

Tree-SHA512: 2cf08f5b356dca25f99b0342645db5253eab0854796cf44fa52f8a6cf28f6d3f973e21589e0f9d3fef40a1b21b3f0aee00c9ca0897109a1967f9ef3320dd508f
@Sjors
Copy link
Member

Sjors commented Mar 29, 2022

I wonder if this was also a problem when creating a wallet, see #571.

@bitcoin-core bitcoin-core locked and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working Wallet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

qt, wallet: wallet does not lock after first send
6 participants