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

Do not exit and re-enter main event loop during shutdown #336

Merged
merged 10 commits into from
Sep 30, 2021

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented May 16, 2021

On master (1ef34ee) during shutdown QApplication exits the main event loop, then re-enter again.

This PR streamlines shutdown process by removing the need to interrupt the main event loop, that is required for #59.

Also, blocking QDialog::exec() calls are replaced with safer QDialog::show(), except for SendConfirmationDialog as that change is not trivial (marked as TODO).

The QDialog::open() was not used because the actual modality mode (application modal or window modal) of a dialog depends on whether it has a parent.

This PR does not change behavior, and all touched dialogs are still application modal.
As a follow up, a design research could suggest to make some dialogs window modal.

NOTE for reviewers: quitting app while a dialog is open (e.g., via systray icon menu) must work fine.

@hebasto hebasto marked this pull request as draft May 16, 2021 22:46
@hebasto hebasto marked this pull request as ready for review May 16, 2021 22:53
Copy link
Member

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

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

Concept ACK, Tested that each commit can compile and run on its own.

Testing on macOS, some of the dialogs will now open in a subwindow instead of its own window. Here is an example of this:

Master PR
Screen Shot 2021-05-17 at 7 01 48 PM Screen Shot 2021-05-17 at 7 00 06 PM

Specifically the OptionsDialog, EditAddressDialog, AskPassphraseDialog undergo this change compared to master. Interestingly, CoinControlDialog, PSBTOperationsDialog, and HelpMessageDialog all still open up in their own window. It is surprising to me that one set of dialogs behave differently from another set under these changes.

@hebasto
Copy link
Member Author

hebasto commented May 19, 2021

Updated 09e84de -> 77a9261 (pr336.02 -> pr336.03, diff):

@hebasto
Copy link
Member Author

hebasto commented May 29, 2021

Rebased 77a9261 -> 0f2fff3 (pr336.03 -> pr336.04) on top of the recent CI changes.

@hebasto
Copy link
Member Author

hebasto commented Jun 7, 2021

Added a note for reviewers to the OP.

@hebasto
Copy link
Member Author

hebasto commented Jun 7, 2021

Updated 0f2fff3 -> 2ad7b4d (pr336.04 -> pr336.05):

  • addressed @promag's comment
  • rebased on top of the recent GUI changes (signal-slot connection etc)

src/qt/guiutil.h Outdated Show resolved Hide resolved
@hebasto
Copy link
Member Author

hebasto commented Jun 11, 2021

Updated 2ad7b4d -> b441b47 (pr336.05 -> pr336.06):

@hebasto
Copy link
Member Author

hebasto commented Jul 22, 2021

Rebased b441b47 -> d6dd44c (pr336.06 -> pr336.07) due to the conflict with #381.

@hebasto
Copy link
Member Author

hebasto commented Aug 14, 2021

Rebased d6dd44c -> 950ed3c (pr336.07 -> pr336.08) due to the conflict with #399.

@hebasto
Copy link
Member Author

hebasto commented Aug 26, 2021

Rebased 950ed3c -> 2407f0d (pr336.08 -> pr336.09) due to the conflict with #403.

@hebasto
Copy link
Member Author

hebasto commented Sep 7, 2021

Rebased 2407f0d -> 94c395d (pr336.09 -> pr336.10) due to the conflict with #398.

@laanwj
Copy link
Member

laanwj commented Sep 29, 2021

Concept ACK

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Tested ACK 94c395d.

I've tested quitting in different cases, with some dialogs opened, also with the stop RPC command.

Checked all call sites affected by the change to non-blocking.

src/qt/bitcoingui.h Outdated Show resolved Hide resolved
@hebasto
Copy link
Member Author

hebasto commented Sep 29, 2021

Updated 94c395d -> 451ca24 (pr336.10 -> pr336.11, diff):

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

ACK 451ca24, just changed signal to quitRequested.

@hebasto
Copy link
Member Author

hebasto commented Sep 29, 2021

@shaavan

tACK 2407f0d
Tested on Ubuntu 20.04 (Qt version 5.12.8)
I tested all the commits and didn’t observe any changes in functionality.

Would you mind re-reviewing this PR after the recent changes?

@shaavan
Copy link
Contributor

shaavan commented Sep 29, 2021

Would you mind re-reviewing this PR after the recent changes?

Let me take a look!

@laanwj
Copy link
Member

laanwj commented Sep 30, 2021

Code review and lighly tested ACK 451ca24

@laanwj laanwj merged commit 81e7748 into bitcoin-core:master Sep 30, 2021
@hebasto hebasto deleted the 210516-loop branch September 30, 2021 10:04
Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

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

Post-merge ACK 451ca24

Changes since my last review:

  • PR was rebased on Master
  • Function QuitClicked is renamed to QuitRequested

Tested successfully again on Ubuntu 20.04 (Using Qt version 5.12.8), with no change in functionality. Thanks for this fantastic work @hebasto!

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 30, 2021
@ghost
Copy link

ghost commented Dec 16, 2021

@hebasto Can we revert the changes made in this pull request?

@hebasto
Copy link
Member Author

hebasto commented Dec 16, 2021

@prayank23

@hebasto Can we revert the changes made in this pull request?

I'm working on bitcoin/bitcoin#23790

@hebasto
Copy link
Member Author

hebasto commented Dec 17, 2021

@prayank23

Can we revert the changes made in this pull request?

Blocking synchronous dialogs are evil for responsible GUI. Only broken part was reverted in #509.

@ghost
Copy link

ghost commented Dec 17, 2021

Blocking synchronous dialogs are evil for responsible GUI. Only broken part was reverted in #509.

Compiling PR branch. Will test and comment in PR. Thanks.

hebasto added a commit to bitcoin/bitcoin that referenced this pull request Feb 15, 2022
…ion in wallet unlock

f730bd7 scripted-diff: Rename ShowModalDialogAndDeleteOnClose (Hennadii Stepanov)
5d7666b qt: Revert 7fa91e8 partially (Hennadii Stepanov)
89c277a qt: Delay shutdown while a modal dialog is active (Hennadii Stepanov)
8c0eb80 qt: Disable tray icon menu when a modal dialog is active (Hennadii Stepanov)
9242735 qt, refactor: Use local QAction instances for the tray icon menu (Hennadii Stepanov)
58e1603 qt, refactor: Drop BitcoinGUI::{send,receive}CoinsMenuAction members (Hennadii Stepanov)
fd667e7 qt: Make show_hide_action dependent on the main window actual state (Hennadii Stepanov)
ee151d0 qt: Drop BitcoinGUI::toggleHideAction member (Hennadii Stepanov)
78189da qt, refactor: Fill up trayIconMenu before connections (Hennadii Stepanov)
66afa28 qt, refactor: Replace BitcoinGUI::trayIconActivated with a lambda (Hennadii Stepanov)
c3ca836 qt, refactor: Replace BitcoinGUI::macosDockIconActivated with a lambda (Hennadii Stepanov)

Pull request description:

  As pointed in #23790 a regression in wallet unlock was introduced in bitcoin-core/gui#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](https://user-images.githubusercontent.com/32963518/146580710-0a755f24-a166-414b-be60-7863232ac778.png)

  This is confusing and must be avoided.

  Fixes #23790.

ACKs for top commit:
  prayank23:
    tACK bitcoin-core/gui@f730bd7

Tree-SHA512: 2b68275754190e4a9831b96e882d3c5b005e03909aeb6f2c5846da07199bb3efbb74ce87a9d25bb139f643c43d377a2051b221d553281fa5aefdd3181a58077f
hebasto added a commit that referenced this pull request Feb 22, 2022
e7fc506 qt: Override BitcoinApplication::event() to handle QEvent::Quit (Hennadii Stepanov)

Pull request description:

  #336 introduced a regression when termination requests from a platform are not handled properly.

  This PR fixes this regression. On macOS shutdown after clicking "Quit" in Dock icon menu, and during logout works again.

  Fixes #545.

ACKs for top commit:
  RandyMcMillan:
    tACK e7fc506
  Sjors:
    tACK e7fc506 (rebased on master) indeed fixes the crash described in #545
  promag:
    Tested ACK e7fc506 on macOS 10.15 with Qt 5.15.2.

Tree-SHA512: 236a483dc0828f22999469e133b8ac9f0b6267ec2a27004c3ebaa967689ddb972ea1fa90c1dd41f3bff3d17bf571a707babcef53bd79fd711fda98cfbf120131
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 22, 2022
…andle QEvent::Quit

e7fc506 qt: Override BitcoinApplication::event() to handle QEvent::Quit (Hennadii Stepanov)

Pull request description:

  bitcoin-core/gui#336 introduced a regression when termination requests from a platform are not handled properly.

  This PR fixes this regression. On macOS shutdown after clicking "Quit" in Dock icon menu, and during logout works again.

  Fixes bitcoin-core/gui#545.

ACKs for top commit:
  RandyMcMillan:
    tACK e7fc506
  Sjors:
    tACK e7fc506 (rebased on master) indeed fixes the crash described in #545
  promag:
    Tested ACK e7fc506 on macOS 10.15 with Qt 5.15.2.

Tree-SHA512: 236a483dc0828f22999469e133b8ac9f0b6267ec2a27004c3ebaa967689ddb972ea1fa90c1dd41f3bff3d17bf571a707babcef53bd79fd711fda98cfbf120131
@bitcoin-core bitcoin-core locked and limited conversation to collaborators Dec 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants