Skip to content

Commit 4bd7187

Browse files
author
MarcoFalke
committed
Merge #15699: Remove no-op CClientUIInterface::[signal_name]_disconnect. Disconnect BlockNotifyGenesisWait and RPCNotifyBlockChange properly.
6dd469a Disconnect BlockNotifyGenesisWait and RPCNotifyBlockChange properly. Remove no-op CClientUIInterface::[signal_name]_disconnect. (practicalswift) Pull request description: Resolves #15698. Changes: * Remove no-op `CClientUIInterface::[signal_name]_disconnect`. * Disconnect `BlockNotifyGenesisWait` and `RPCNotifyBlockChange` properly. ACKs for commit 6dd469: MarcoFalke: utACK 6dd469a Tree-SHA512: 0b50d658fa72261332bc57ddea379fd08f4bc1de392c10c628e20142d6fd244b606c39fd0665d6bc39324c1aa8c8814ac942b4659106279e33b90206aaf37411
2 parents e9e777e + 6dd469a commit 4bd7187

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/init.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,15 @@ static void registerSignalHandler(int signal, void(*handler)(int))
345345
}
346346
#endif
347347

348+
static boost::signals2::connection rpc_notify_block_change_connection;
348349
static void OnRPCStarted()
349350
{
350-
uiInterface.NotifyBlockTip_connect(&RPCNotifyBlockChange);
351+
rpc_notify_block_change_connection = uiInterface.NotifyBlockTip_connect(&RPCNotifyBlockChange);
351352
}
352353

353354
static void OnRPCStopped()
354355
{
355-
uiInterface.NotifyBlockTip_disconnect(&RPCNotifyBlockChange);
356+
rpc_notify_block_change_connection.disconnect();
356357
RPCNotifyBlockChange(false, nullptr);
357358
g_best_block_cv.notify_all();
358359
LogPrint(BCLog::RPC, "RPC stopped.\n");
@@ -1733,8 +1734,9 @@ bool AppInitMain(InitInterfaces& interfaces)
17331734

17341735
// Either install a handler to notify us when genesis activates, or set fHaveGenesis directly.
17351736
// No locking, as this happens before any background thread is started.
1737+
boost::signals2::connection block_notify_genesis_wait_connection;
17361738
if (chainActive.Tip() == nullptr) {
1737-
uiInterface.NotifyBlockTip_connect(BlockNotifyGenesisWait);
1739+
block_notify_genesis_wait_connection = uiInterface.NotifyBlockTip_connect(BlockNotifyGenesisWait);
17381740
} else {
17391741
fHaveGenesis = true;
17401742
}
@@ -1758,7 +1760,7 @@ bool AppInitMain(InitInterfaces& interfaces)
17581760
while (!fHaveGenesis && !ShutdownRequested()) {
17591761
g_genesis_wait_cv.wait_for(lock, std::chrono::milliseconds(500));
17601762
}
1761-
uiInterface.NotifyBlockTip_disconnect(BlockNotifyGenesisWait);
1763+
block_notify_genesis_wait_connection.disconnect();
17621764
}
17631765

17641766
if (ShutdownRequested()) {

src/ui_interface.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ struct UISignals {
2828
boost::signals2::connection CClientUIInterface::signal_name##_connect(std::function<signal_name##Sig> fn) \
2929
{ \
3030
return g_ui_signals.signal_name.connect(fn); \
31-
} \
32-
void CClientUIInterface::signal_name##_disconnect(std::function<signal_name##Sig> fn) \
33-
{ \
34-
return g_ui_signals.signal_name.disconnect(&fn); \
3531
}
3632

3733
ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeMessageBox);

src/ui_interface.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ class CClientUIInterface
8181
#define ADD_SIGNALS_DECL_WRAPPER(signal_name, rtype, ...) \
8282
rtype signal_name(__VA_ARGS__); \
8383
using signal_name##Sig = rtype(__VA_ARGS__); \
84-
boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn); \
85-
void signal_name##_disconnect(std::function<signal_name##Sig> fn);
84+
boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn);
8685

8786
/** Show message box. */
8887
ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const std::string& message, const std::string& caption, unsigned int style);

0 commit comments

Comments
 (0)