From fa4903db8a3cf5a047dba5e5929d4e2250e0e744 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 9 Apr 2026 17:14:05 +0200 Subject: [PATCH] refactor: Make scoped_connection ctor explicit This ensures that all constructions of scoped connections are explict, making the intent explicit and review easier. This also follows the default recommendation from https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit --- src/btcsignals.h | 2 +- src/qt/bitcoin.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/btcsignals.h b/src/btcsignals.h index e0df8ae8adb..b990fb9d8ea 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 bf42f78da04..47790eb3abd 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