refactor: [gui] Use lambdas over std::bind
What changed, and why it matters
This is a straightforward code cleanup in Bitcoin Core's graphical user interface. It replaces older-style std::bind calls with modern C++ lambda functions when connecting internal message-box and question handlers. There is no security-relevant change: the same functions are called with the same arguments, and no behavior changes.
No security action needed. Treat as normal code-quality refactor during review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors two signal handler registrations in src/qt/bitcoingui.cpp from std::bind to lambdas. The lambda bodies forward identical parameters to the existing static ThreadSafeMessageBox helper. The second lambda explicitly names but ignores the non_interactive_message parameter, matching the previous std::bind placeholder skipping behavior. No functional change; the
Changed components
src/qt/bitcoingui.cppInspect captured patch +6 / −4
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index dc4a8271..69efff6e 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -41,8 +41,6 @@
#include <util/translation.h>
#include <validation.h>
-#include <functional>
-
#include <QAction>
#include <QActionGroup>
#include <QApplication>
@@ -1617,8 +1615,12 @@ static bool ThreadSafeMessageBox(BitcoinGUI* gui, const bilingual_str& message,
void BitcoinGUI::subscribeToCoreSignals()
{
// Connect signals to client
- m_handler_message_box = m_node.handleMessageBox(std::bind(ThreadSafeMessageBox, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
- m_handler_question = m_node.handleQuestion(std::bind(ThreadSafeMessageBox, this, std::placeholders::_1, std::placeholders::_3, std::placeholders::_4));
+ m_handler_message_box = m_node.handleMessageBox([this](const bilingual_str& message, const std::string& caption, unsigned int style) {
+ return ThreadSafeMessageBox(this, message, caption, style);
+ });
+ m_handler_question = m_node.handleQuestion([this](const bilingual_str& message, const std::string& /*non_interactive_message*/, const std::string& caption, unsigned int style) {
+ return ThreadSafeMessageBox(this, message, caption, style);
+ });
}
void BitcoinGUI::unsubscribeFromCoreSignals()
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.