Skip to content

Commit 0038e53

Browse files
committed
Merge #17965: qt: Revert changes of pr17943
70e4706 Revert "refactor: Remove never used default parameter" (Hennadii Stepanov) 219417b Revert "refactor: Simplify connection syntax" (Hennadii Stepanov) Pull request description: The code, the `bool* ret = nullptr` parameter in the `BitcoinGUI::message()` slot, removed in #17943 is not dead actually. It is used in `ThreadSafeMessageBox()` function: https://github.com/bitcoin/bitcoin/blob/a654626f076a72416a3d354218d7107571d6caaf/src/qt/bitcoingui.cpp#L1363-L1368 Now in master (a654626): ``` $ ./src/qt/bitcoin-qt -prune=-1 Error: Prune cannot be configured with a negative value. bitcoin-qt: qt/bitcoingui.cpp:1369: bool ThreadSafeMessageBox(BitcoinGUI*, const string&, const string&, unsigned int): Assertion `invoked' failed. Aborted (core dumped) ``` This PR reverts all commits of #17943 Additional notes: the bug was missed due to dynamic function call `QMetaObject::invokeMethod()` which cannot be checked at compile time. See #16348 for more discussion. Sorry for introducing a bug. ACKs for top commit: Sjors: ACK 70e4706 laanwj: ACK 70e4706 Tree-SHA512: b968a026eaa4f5f39fd36ddc715d8e233f3c6420e6580f11d4ca422a5ff5d1d9d3df9ac11b353c3d4f434d67d6a69e37d2e26b8248d72bedd14ecba0a545a327
2 parents 0a8b68c + 70e4706 commit 0038e53

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

src/qt/bitcoin.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,9 @@ void BitcoinApplication::initializeResult(bool success)
361361
if (paymentServer) {
362362
connect(paymentServer, &PaymentServer::receivedPaymentRequest, window, &BitcoinGUI::handlePaymentRequest);
363363
connect(window, &BitcoinGUI::receivedURI, paymentServer, &PaymentServer::handleURIOrFile);
364-
connect(paymentServer, &PaymentServer::message, window, &BitcoinGUI::message);
364+
connect(paymentServer, &PaymentServer::message, [this](const QString& title, const QString& message, unsigned int style) {
365+
window->message(title, message, style);
366+
});
365367
QTimer::singleShot(100, paymentServer, &PaymentServer::uiReady);
366368
}
367369
#endif

src/qt/bitcoingui.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,9 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
564564
connect(_clientModel, &ClientModel::numBlocksChanged, this, &BitcoinGUI::setNumBlocks);
565565

566566
// Receive and report messages from client model
567-
connect(_clientModel, &ClientModel::message, this, &BitcoinGUI::message);
567+
connect(_clientModel, &ClientModel::message, [this](const QString &title, const QString &message, unsigned int style){
568+
this->message(title, message, style);
569+
});
568570

569571
// Show progress dialog
570572
connect(_clientModel, &ClientModel::showProgress, this, &BitcoinGUI::showProgress);
@@ -1025,7 +1027,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
10251027
progressBar->setToolTip(tooltip);
10261028
}
10271029

1028-
void BitcoinGUI::message(const QString& title, QString message, unsigned int style)
1030+
void BitcoinGUI::message(const QString& title, QString message, unsigned int style, bool* ret)
10291031
{
10301032
// Default title. On macOS, the window title is ignored (as required by the macOS Guidelines).
10311033
QString strTitle{PACKAGE_NAME};
@@ -1079,7 +1081,9 @@ void BitcoinGUI::message(const QString& title, QString message, unsigned int sty
10791081
showNormalIfMinimized();
10801082
QMessageBox mBox(static_cast<QMessageBox::Icon>(nMBoxIcon), strTitle, message, buttons, this);
10811083
mBox.setTextFormat(Qt::PlainText);
1082-
mBox.exec();
1084+
int r = mBox.exec();
1085+
if (ret != nullptr)
1086+
*ret = r == QMessageBox::Ok;
10831087
} else {
10841088
notificator->notify(static_cast<Notificator::Class>(nNotifyIcon), strTitle, message);
10851089
}

src/qt/bitcoingui.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ public Q_SLOTS:
219219
@param[in] message the displayed text
220220
@param[in] style modality and style definitions (icon and used buttons - buttons only for message boxes)
221221
@see CClientUIInterface::MessageBoxFlags
222+
@param[in] ret pointer to a bool that will be modified to whether Ok was clicked (modal only)
222223
*/
223-
void message(const QString& title, QString message, unsigned int style);
224+
void message(const QString& title, QString message, unsigned int style, bool* ret = nullptr);
224225

225226
#ifdef ENABLE_WALLET
226227
void setCurrentWallet(WalletModel* wallet_model);

src/qt/walletview.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ void WalletView::setBitcoinGUI(BitcoinGUI *gui)
9797
connect(sendCoinsPage, &SendCoinsDialog::coinsSent, gui, &BitcoinGUI::gotoHistoryPage);
9898

9999
// Receive and report messages
100-
connect(this, &WalletView::message, gui, &BitcoinGUI::message);
100+
connect(this, &WalletView::message, [gui](const QString &title, const QString &message, unsigned int style) {
101+
gui->message(title, message, style);
102+
});
101103

102104
// Pass through encryption status changed signals
103105
connect(this, &WalletView::encryptionStatusChanged, gui, &BitcoinGUI::updateWalletStatus);

0 commit comments

Comments
 (0)