aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoingui.cpp
diff options
context:
space:
mode:
authorW. J. van der Laan <laanwj@protonmail.com>2021-09-30 10:26:37 +0200
committerW. J. van der Laan <laanwj@protonmail.com>2021-09-30 11:35:15 +0200
commit81e7748bc18aef167a6aed07c96d85bf00c5929e (patch)
tree3ee7782471f7f7cb8730b6dcbd71c1ced6085ae4 /src/qt/bitcoingui.cpp
parentf52929063f4811d460b40c80da309aa6c40a9410 (diff)
parent451ca244db8bc71ffc3cc9982d025f144cc8f3bc (diff)
downloadbitcoin-81e7748bc18aef167a6aed07c96d85bf00c5929e.tar.xz
Merge bitcoin-core/gui#336: Do not exit and re-enter main event loop during shutdown
451ca244db8bc71ffc3cc9982d025f144cc8f3bc qt, refactor: Drop intermediate BitcoinApplication::shutdownResult slot (Hennadii Stepanov) f3a17bbe5f7d23b6ecc20e363920492b50859dad qt: Do not exit and re-enter main event loop during shutdown (Hennadii Stepanov) b4e0d2c43181ad97c15b252e95181e2c3f6c1d2a qt, refactor: Allocate SendConfirmationDialog instances on heap (Hennadii Stepanov) 332dea2852d9c68f900ed1f0be99b6cea79c7457 qt, refactor: Keep HelpMessageDialog in the main event loop (Hennadii Stepanov) c8bae37a7a646badf8e79669bf06ac174e13cd6f qt, refactor: Keep PSBTOperationsDialog in the main event loop (Hennadii Stepanov) 7fa91e831227e556bd8a7ae3da64bd59d4f30d5f qt, refactor: Keep AskPassphraseDialog in the main event loop (Hennadii Stepanov) 6f6fde30e7601185a8f6052b3bf1770407fcc14b qt, refactor: Keep EditAddressDialog in the main event loop (Hennadii Stepanov) 59f7ba4fd7a9e4bc73d784ee74d5b777da9cc436 qt, refactor: Keep CoinControlDialog in the main event loop (Hennadii Stepanov) 7830cd0b35f315570d744f4d2719104c08b33ff1 qt, refactor: Keep OptionsDialog in the main event loop (Hennadii Stepanov) 13f618818dc57673ac0287ad8b28ceb450efb374 qt: Add GUIUtil::ShowModalDialogAndDeleteOnClose (Hennadii Stepanov) Pull request description: On master (1ef34ee25ed34b2b092f15bf3dca5c0508092829) 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()`](https://doc.qt.io/qt-5/qdialog.html#exec) calls are replaced with safer [`QDialog::show()`](https://doc.qt.io/qt-5/qwidget.html#show), except for `SendConfirmationDialog` as that change is not trivial (marked as TODO). The [`QDialog::open()`](https://doc.qt.io/qt-5/qdialog.html#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. ACKs for top commit: laanwj: Code review and lighly tested ACK 451ca244db8bc71ffc3cc9982d025f144cc8f3bc promag: ACK 451ca244db8bc71ffc3cc9982d025f144cc8f3bc, just changed signal to `quitRequested`. Tree-SHA512: ef01ab6ed803b202e776019a4e1f592e816f7bc786e00574b25a0bf16be2374ddf9db21f0a26da08700df7ef0ab9e879550df46dcfe3b6d940f5ed02ca5f8447
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r--src/qt/bitcoingui.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 2ffb6e650b..af05f35759 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -373,7 +373,7 @@ void BitcoinGUI::createActions()
m_mask_values_action->setStatusTip(tr("Mask the values in the Overview tab"));
m_mask_values_action->setCheckable(true);
- connect(quitAction, &QAction::triggered, qApp, QApplication::quit);
+ connect(quitAction, &QAction::triggered, this, &BitcoinGUI::quitRequested);
connect(aboutAction, &QAction::triggered, this, &BitcoinGUI::aboutClicked);
connect(aboutQtAction, &QAction::triggered, qApp, QApplication::aboutQt);
connect(optionsAction, &QAction::triggered, this, &BitcoinGUI::optionsClicked);
@@ -850,8 +850,8 @@ void BitcoinGUI::aboutClicked()
if(!clientModel)
return;
- HelpMessageDialog dlg(this, true);
- dlg.exec();
+ auto dlg = new HelpMessageDialog(this, /* about */ true);
+ GUIUtil::ShowModalDialogAndDeleteOnClose(dlg);
}
void BitcoinGUI::showDebugWindow()
@@ -992,10 +992,11 @@ void BitcoinGUI::openOptionsDialogWithTab(OptionsDialog::Tab tab)
if (!clientModel || !clientModel->getOptionsModel())
return;
- OptionsDialog dlg(this, enableWallet);
- dlg.setCurrentTab(tab);
- dlg.setModel(clientModel->getOptionsModel());
- dlg.exec();
+ auto dlg = new OptionsDialog(this, enableWallet);
+ connect(dlg, &OptionsDialog::quitOnReset, this, &BitcoinGUI::quitRequested);
+ dlg->setCurrentTab(tab);
+ dlg->setModel(clientModel->getOptionsModel());
+ GUIUtil::ShowModalDialogAndDeleteOnClose(dlg);
}
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header, SynchronizationState sync_state)
@@ -1218,7 +1219,7 @@ void BitcoinGUI::closeEvent(QCloseEvent *event)
// close rpcConsole in case it was open to make some space for the shutdown window
rpcConsole->close();
- QApplication::quit();
+ Q_EMIT quitRequested();
}
else
{
@@ -1412,7 +1413,7 @@ void BitcoinGUI::detectShutdown()
{
if(rpcConsole)
rpcConsole->hide();
- qApp->quit();
+ Q_EMIT quitRequested();
}
}