Merge bitcoin/bitcoin#34373: refactor: Remove remaining std::bind, check via clang-tidy
fad042235brefactor: Remove remaining std::bind, check via clang-tidy (MarcoFalke) Pull request description: `std::bind` has many issues: * It is verbose in a meaningless way * Overriden args are silently accepted and dropped at runtime without a compile error. Same for accidental duplicates. One could use `std::bind_front` similar to commitfa267551c4. Though, I think the remaining cases are better off with lambdas. So do that here, and enable the `modernize-avoid-bind` clang-tidy rule to avoid `std::bind` bugs in the future. ACKs for top commit: fjahr: Code review ACKfad042235bpurpleKarrot: Code review ACKfad042235bTree-SHA512: 38b17e26eda3ae47d84a8c34298309dc1eeb4ed434fda58b5803ef031c4c2edfb17222f5208f37af727bf340e32b37c7f81784f461d2b65fbc6227f3cd53eea4
This commit is contained in:
4 files changed
+16
-5
No files matched your search
@@ -10,6 +10,7 @@ bugprone-unhandled-self-assignment,
|
|||||||
bugprone-unused-return-value,
|
bugprone-unused-return-value,
|
||||||
misc-unused-using-decls,
|
misc-unused-using-decls,
|
||||||
misc-no-recursion,
|
misc-no-recursion,
|
||||||
|
modernize-avoid-bind,
|
||||||
modernize-deprecated-headers,
|
modernize-deprecated-headers,
|
||||||
modernize-use-default-member-init,
|
modernize-use-default-member-init,
|
||||||
modernize-use-emplace,
|
modernize-use-emplace,
|
||||||
|
|||||||
@@ -180,8 +180,12 @@ static void ShowProgress(SplashScreen *splash, const std::string &title, int nPr
|
|||||||
void SplashScreen::subscribeToCoreSignals()
|
void SplashScreen::subscribeToCoreSignals()
|
||||||
{
|
{
|
||||||
// Connect signals to client
|
// Connect signals to client
|
||||||
m_handler_init_message = m_node->handleInitMessage(std::bind(InitMessage, this, std::placeholders::_1));
|
m_handler_init_message = m_node->handleInitMessage([this](const std::string& message) {
|
||||||
m_handler_show_progress = m_node->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
InitMessage(this, message);
|
||||||
|
});
|
||||||
|
m_handler_show_progress = m_node->handleShowProgress([this](const std::string& title, int nProgress, bool resume_possible) {
|
||||||
|
ShowProgress(this, title, nProgress, resume_possible);
|
||||||
|
});
|
||||||
m_handler_init_wallet = m_node->handleInitWallet([this]() { handleLoadWallet(); });
|
m_handler_init_wallet = m_node->handleInitWallet([this]() { handleLoadWallet(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +194,9 @@ void SplashScreen::handleLoadWallet()
|
|||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if (!WalletModel::isWalletEnabled()) return;
|
if (!WalletModel::isWalletEnabled()) return;
|
||||||
m_handler_load_wallet = m_node->walletLoader().handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) {
|
m_handler_load_wallet = m_node->walletLoader().handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) {
|
||||||
m_connected_wallet_handlers.emplace_back(wallet->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, false)));
|
m_connected_wallet_handlers.emplace_back(wallet->handleShowProgress([this](const std::string& title, int nProgress) {
|
||||||
|
ShowProgress(this, title, nProgress, /*resume_possible=*/false);
|
||||||
|
}));
|
||||||
m_connected_wallets.emplace_back(std::move(wallet));
|
m_connected_wallets.emplace_back(std::move(wallet));
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -712,7 +712,9 @@ void TransactionTablePriv::DispatchNotifications()
|
|||||||
void TransactionTableModel::subscribeToCoreSignals()
|
void TransactionTableModel::subscribeToCoreSignals()
|
||||||
{
|
{
|
||||||
// Connect signals to wallet
|
// Connect signals to wallet
|
||||||
m_handler_transaction_changed = walletModel->wallet().handleTransactionChanged(std::bind(&TransactionTablePriv::NotifyTransactionChanged, priv, std::placeholders::_1, std::placeholders::_2));
|
m_handler_transaction_changed = walletModel->wallet().handleTransactionChanged([this](const Txid& hash, ChangeType status) {
|
||||||
|
priv->NotifyTransactionChanged(hash, status);
|
||||||
|
});
|
||||||
m_handler_show_progress = walletModel->wallet().handleShowProgress([this](const std::string&, int progress) {
|
m_handler_show_progress = walletModel->wallet().handleShowProgress([this](const std::string&, int progress) {
|
||||||
priv->m_loading = progress < 100;
|
priv->m_loading = progress < 100;
|
||||||
priv->DispatchNotifications();
|
priv->DispatchNotifications();
|
||||||
|
|||||||
@@ -3550,7 +3550,9 @@ void CWallet::ConnectScriptPubKeyManNotifiers()
|
|||||||
{
|
{
|
||||||
for (const auto& spk_man : GetActiveScriptPubKeyMans()) {
|
for (const auto& spk_man : GetActiveScriptPubKeyMans()) {
|
||||||
spk_man->NotifyCanGetAddressesChanged.connect(NotifyCanGetAddressesChanged);
|
spk_man->NotifyCanGetAddressesChanged.connect(NotifyCanGetAddressesChanged);
|
||||||
spk_man->NotifyFirstKeyTimeChanged.connect(std::bind(&CWallet::MaybeUpdateBirthTime, this, std::placeholders::_2));
|
spk_man->NotifyFirstKeyTimeChanged.connect([this](const ScriptPubKeyMan*, int64_t time) {
|
||||||
|
MaybeUpdateBirthTime(time);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user