refactor: Make scoped_connection ctor explicit
What changed, and why it matters
This is a minor code cleanup change that makes a single-argument constructor require explicit syntax. It does not fix a security bug or change runtime behavior; it only prevents accidental automatic type conversions during compilation.
No security action required. Treat as ordinary refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit marks the single-argument constructor of btcsignals::scoped_connection as explicit and updates the three call sites in src/qt/bitcoin.cpp to use braced direct-initialization. This follows C++ Core Guideline C46 and eliminates the possibility of implicit conversions from connection to scoped_connection. There is no functional or security change at runtime.
Changed components
src/btcsignals.hsrc/qt/bitcoin.cppInspect captured patch +4 / −4
diff --git a/src/btcsignals.h b/src/btcsignals.h
index e0df8ae8..b990fb9d 100644
--- a/src/btcsignals.h
+++ b/src/btcsignals.h
@@ -122,7 +122,7 @@ class scoped_connection
connection m_conn;
public:
- scoped_connection(connection rhs) noexcept : m_conn{std::move(rhs)} {}
+ explicit scoped_connection(connection rhs) noexcept : m_conn{std::move(rhs)} {}
scoped_connection(scoped_connection&&) noexcept = default;
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index bf42f78d..47790eb3 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -485,9 +485,9 @@ int GuiMain(int argc, char* argv[])
util::ThreadSetInternalName("main");
// Subscribe to global signals from core
- btcsignals::scoped_connection handler_message_box = ::uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBox);
- btcsignals::scoped_connection handler_question = ::uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestion);
- btcsignals::scoped_connection handler_init_message = ::uiInterface.InitMessage_connect(noui_InitMessage);
+ btcsignals::scoped_connection handler_message_box{::uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBox)};
+ btcsignals::scoped_connection handler_question{::uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestion)};
+ btcsignals::scoped_connection handler_init_message{::uiInterface.InitMessage_connect(noui_InitMessage)};
// Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory
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.